GitBucket
Toggle navigation
Pull requests
Issues
Snippets
Sign in
Files
Branches
1
Releases
Issues
Pull requests
Labels
Priorities
Milestones
Wiki
Fork
: 0
sample-golang
/
01_hello
Download ZIP
22 commits
Transfer to URL with SHA
tree:
0dd4767ab5
Branches
Tags
×
master
01_hello
/
func
/
latest commit
0dd4767ab5
yhornisse
authored
on 27 Sep 2021
..
sub
add func and package sample
4 years ago
README.md
add bare return sample
4 years ago
bareReturn.go
add bare return sample
4 years ago
defer.go
add sample
4 years ago
func.go
add sample code
4 years ago
go.mod
add func and package sample
4 years ago
loop.go
add sample
4 years ago
README.md
MEMO
戻り値は複数定義できる。エラー通知や成功失敗などにはこれが使える。
返却値を捨てる場合は
_
を指定する。
引数をstructや配列をそのまま指定すると値渡し、ポインタを指定すれば参照渡しになる
速度を気にするなら参照渡し
パッケージ分ける場合はgo.modとか使うと便利。
go mod init xxxx/xxx
とかで初期化できる。
パッケージでリモートのパスを使う場合
go help importpath
で確認できるようなものが使える(Githubとか)
replaceを定義しておけばローカルでもリモートでもビルドできる。
違うパッケージからアクセスするには大文字始まりの名前にする必要がある。
空returnを使うと効率的な場合があるが、返却値が明示的でない場合があるので控えめに使う方が良いとのこと( bareReturn.goを参照 )