add func and package sample
1 parent 14d6d12 commit b6be082e6b3769787f0ed22cd8032f020a2c7189
yhornisse authored on 27 Sep 2021
Showing 4 changed files
View
9
func/README.md 0 → 100644
## MEMO
 
- 引数をstructや配列をそのまま指定すると値渡し、ポインタを指定すれば参照渡しになる
- 速度を気にするなら参照渡し
- パッケージ分ける場合はgo.modとか使うと便利。`go mod init xxxx/xxx`とかで初期化できる。
- パッケージでリモートのパスを使う場合`go help importpath`で確認できるようなものが使える(Githubとか)
- replaceを定義しておけばローカルでもリモートでもビルドできる。
 
View
30
func/func.go 0 → 100644
package main
 
import (
"fmt"
"localhost/hello/sub"
)
 
func hello() {
fmt.Println("hello")
}
 
func hoge() (int64, int64, int64) {
return 1, 2, 3
}
 
func println(str string) {
fmt.Println(str)
}
 
func main() {
hello()
println("println")
sub.Sample()
 
v1, v2, v3 := hoge()
fmt.Print(v1, v2, v3) // 1 2 3
fmt.Println()
}
 
View
func/go.mod 0 → 100644
View
func/sub/sample.go 0 → 100644