Note #31 go run и exit code
Вчера в твиттере увидел как Джонни Бурсиквот задает вопрос[1]: почему
Крутой коммент от Дэйва Чейни (перевод):
“Go run - это для игрушечных программ, серьезные программы нужно компилировать и запускать” :lol:
Вот часть исходника go run [3] “We ignore exit status.”:
[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
Вчера в твиттере увидел как Джонни Бурсиквот задает вопрос[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Странно почему он не догадался сразу, go run - это 2 процесса и соответственно 2 exit кода, однако go run может вернуть только один exit код :)
./main
$ echo $?
199
Крутой коммент от Дэйва Чейни (перевод):
“Go run - это для игрушечных программ, серьезные программы нужно компилировать и запускать” :lol:
Вот часть исходника go run [3] “We ignore exit status.”:
// buildRunProgram is the action for running a binary that has alreadyLinks:
// been compiled. We ignore exit status.
func buildRunProgram(b *work.Builder, a *work.Action) error {
…
}
[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
Twitter
Johnny Boursiquot
TIL: `go run` will always result in exit code 1, regardless of the exit code you use. For example, it may surprise you that this program does not exit with 199 when you `echo $?` in your shell if you use `go run` to exec it. `go build` does what you'd expect…
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
В официальном #golang блоге появилась статья про новый Go API для Protocol Buffers.
Рекомендую почитать! ->
https://blog.golang.org/a-new-go-api-for-protocol-buffers
go.dev
A new Go API for Protocol Buffers - The Go Programming Language
Go is an open source programming language that makes it easy to build simple, reliable, and efficient software.
Визуализация нового пропозала про дженерики с отличными примерами от Владимир Вивьен
https://twitter.com/vladimirvivien/status/1297595414590427142?s=21
https://twitter.com/vladimirvivien/status/1297595414590427142?s=21
Twitter
Vladimir Vivien
The #golang proposal to introduce generic functions and types (via parametric polymorphism) has been evolving nicely. This 🧵 summarizes what the latest is: - [] sqr brackets to be used for type param - type param must have a constraint - constraint `any`…
Вот интересный твит трэд от Даниэля об изменения в go 1.17 (который выйдет через 7 месяцев):
https://twitter.com/mvdan_/status/1352194794064392192?s=20
https://twitter.com/mvdan_/status/1352194794064392192?s=20
Twitter
Daniel Martí
Here's a short list of the changes to look forward to for #golang 1.17, to start landing once the merge window opens in a few weeks. Don't get confused with 1.16, releasing next month. 1.17 will come out in seven months. Each change with a link, so you can…
🇺🇦 Go for two :)
FOSDEM 2021 Go dev room В этом году FOSDEM пройдет online, в субботу 6 февраля! И уже есть расписание https://fosdem.org/2021/schedule/track/go/
Видео начали заливать https://twitter.com/maartjeme/status/1358101853955883008?s=21
Twitter
Maartje Eyskens 😷
Did you just wake up and missed the #golang devroom? Don't cry All talks are at https://t.co/3s8DCKkZmP just 2 live ones missing but they will be there soon!
Forwarded from 🇺🇦 Go performance channel (Oleg Kovalov)
Making a #golang program 42% faster with a one character change
https://hmarr.com/blog/go-allocation-hunting/
https://hmarr.com/blog/go-allocation-hunting/
Hmarr
Making a Go program run 1.7x faster with a one character change • Harry Marr
Programmer and engineering manager working at GitHub. Co-founded Dependabot, and helped build Monzo and GoCardless.
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)
And by the way... @go_perf
is also available here https://mastodon.cloud/@go_perf and here https://twitter.com/go_perf
is also available here https://mastodon.cloud/@go_perf and here https://twitter.com/go_perf
mastodon.cloud
🇺🇦 Go performance channel (@[email protected])
152 Posts, 14 Following, 240 Followers · #golang performance, runtime, concurrency. Talks, blogposts and open source projects for #gophers (mail: [email protected]). Not affiliated with @golang team.
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/
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)
🎊 Go 1.20 Release Candidate 1 is released!
🏃♂️ Run it in dev! Run it in prod! File bugs! https://go.dev/issue/new
📣 Announcement: https://groups.google.com/g/golang-announce/c/iqUo0Spdl9I
📦 Download: https://go.dev/dl/#go1.20rc1
#golang (via https://twitter.com/golang/status/1600612450197446675)
🏃♂️ Run it in dev! Run it in prod! File bugs! https://go.dev/issue/new
📣 Announcement: https://groups.google.com/g/golang-announce/c/iqUo0Spdl9I
📦 Download: https://go.dev/dl/#go1.20rc1
#golang (via https://twitter.com/golang/status/1600612450197446675)
GitHub
GitHub is where people build software. More than 150 million people use GitHub to discover, fork, and contribute to over 420 million projects.