🇺🇦 Go for two :)
1.18K subscribers
22 photos
3 files
184 links
Telegram channel about tricks and engineering practices in the Go programming language over a cup of coffee ☕️.

author: @a_soldatenko
personal blog: https://asoldatenko.org

#golang #go #kubernetes #debugging
加入频道
Note #31 go run и exit code

Вчера в твиттере увидел как Джонни Бурсиквот задает вопрос[1]: почему go run всегда возвращает exit code 1:
$ cat main.go
package main

import "os"

func main() {
os.Exit(199)
}
$ go run main.go
exit status 199
$ echo $?
1
А если собрать бинарник, а потом запустить то все будет ок:
go build main.go
./main
$ echo $?
199
Странно почему он не догадался сразу, go run - это 2 процесса и соответственно 2 exit кода, однако go run может вернуть только один exit код :)

Крутой коммент от Дэйва Чейни (перевод):
“Go run - это для игрушечных программ, серьезные программы нужно компилировать и запускать” :lol:

Вот часть исходника go run [3] “We ignore exit status.”:
// buildRunProgram is the action for running a binary that has already
// been compiled. We ignore exit status.
func buildRunProgram(b *work.Builder, a *work.Action) error {

}
Links:
[1] Твиттер thread https://twitter.com/jboursiquot/status/1177296876779057152
[2] Issue 2015 года на эту тему: https://github.com/golang/go/issues/13440
[3] https://github.com/golang/go/blob/master/src/cmd/go/internal/run/run.go#L146-L148
Note #63 A new Go API for Protocol Buffers

В официальном #golang блоге появилась статья про новый Go API для Protocol Buffers.

Рекомендую почитать! ->

https://blog.golang.org/a-new-go-api-for-protocol-buffers
Forwarded from 🇺🇦 Go performance channel (Oleg Kovalov)
Nice comment by Brian C. Mills regarding new #golang sync.Map methods https://github.com/golang/go/issues/51972#issuecomment-1315912196
Forwarded from 🇺🇦 Go performance channel (Oleg Kovalov)
Building a custom code search index in #golang for searchcode.com

As always @boyter post are amazing (thanks for doing & writing this!)

https://boyter.org/posts/how-i-built-my-own-index-for-searchcode/
Forwarded from 🇺🇦 Go performance channel (Oleg Kovalov)
In #Golang 1.20 the Go team introduced an experimental new method of memory management called Go arenas.

In this blog post we show how we combined continuous profiling with memory arenas to improve performance of one of our cloud services by ~8% !

https://pyroscope.io/blog/go-1-20-memory-arenas/
My talk has been highlighted in #golang weekly 🤘 https://golangweekly.com/issues/448