golang
実装するのが楽しい
Googleさんちの言語
GUI
go build -ldflags="-H windowsgui"
build
go build -ldflags -s -w -o
CUIツールを作るのに向いているというかすごく作りやすい。
ドキュメント
https://go.dev
用語
context 
https://pkg.go.dev/context
うーん、わからん。。
画面で作るなら react のがいいのかなぁ
Contains
パッケージングのかんどころ
https://future-architect.github.io/articles/20200528/
たしかになぁ
拡張子をなくす方法
filepath.Base
らしいが
めんどくさいので決め打ちの拡張子だったからリプレースにしたった
1.18
https://future-architect.github.io/tags/Go1-18/
ioutilは使わない方がいいという話
https://text.baldanders.info/golang/deprecation-of-ioutil/
こんなエラーが出るようになってた
error obtaining VCS status: exit status 128
Use -buildvcs=false to disable VCS stamping.go
logを標準出力にだしたくないとき
code:sample.go
f, err := os.OpenFile("logfile.log", os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
if err != nil {
log.Fatal(err)
}
defer f.Close()
log.SetOutput(f)
JSONに読み込ませる方法は、、
json.Unmarshal
とかだった気がするんだけど?
$ err = json.NewDecoder(resp.Body).Decode(&getItem)
これだこれ。デコードすればいいんや
MAP配列
$ m := make(mapintstring)
先頭と最後の文字を取得する(マルチバイト文字も含めて)
code:sample.go
msgrune := []rune(msgstr)
result := string(msgrune0)
fmt.Println(result)
resultEnd := string(msgrunelen(msgrune)-1)
fmt.Println(resultEnd)
go:embed
これでローカルファイルの読み込みがしやすくなるみたい
https://pkg.go.dev/embed
コンパイルエラーになってるとき
GOを入れなおしてこれで。
$ winget install GoLang.Go -l E:\Go\GOROOT
$ $env:GOROOT="E:\Go\GOROOT"