result, err := callFoo()
if err != nil {
return nil, err
}
No collection streams means LOTS of mind-numbing/eye-glazing for loops. Things have improved slightly with the slices and maps package but these are just hacks. Maybe with the new iterator support, Go will slowly and steadily get a bit more expressive.Go is good for middleware coding thanks to Go-routines and and excellent networking support in the standard library but is cumbersome slow and inexpressive for scripts.
Also go.mod does NOT separate dev/test/prod dependencies - unlike Java Maven or Rust Cargo. You don't want your script dependencies coming into production code.
Also, in many areas Java's standard library is more expansive.
Also, go run is almost like running a script.
package main
import "fmt"
func main () {
fmt.Println("hi")
}
// go run file.go
You can write this in any text editor, but using one with LSP support means that `import` statement is added automatically, and with CoPilot or another assistant, the `main` function writes itself as well as any `if err ...` statements. Go is extremely well suited to code generation due to how predictable it is.Adding dependencies with `go mod` is uneventful.
It will never be as 'scripty' as JS or Ruby, but the readability, safety and performance are totally worth it.
Is limited features (Go) gonna be better for AI generation then breadth of examples? (C#). I'm not sure.
puts "hi"
And the crystal version is just as typesafe and performant as the go version. I also find it more readable, but that is a very individual metric.As I mentioned, yes, it's verbose, but simple and worth the effort and peace of mind. My primary language is JS, I've written a fair share of shell and Ruby but would still choose go a lot of the time, just because it doesn't pull in any extra complexity.
It was really dumb, but that's what the client needed. So much cross compiling.
This is part of my standard Go build.sh script. You just never know who might want to run a given thing where.
GOOS=linux GOARCH=amd64 go build
GOOS=linux GOARCH=arm64 go build
GOOS=darwin GOARCH=amd64 go build
Which again, let's me distribute a binary to my end user as a single file, without directing them to install java or python3 or whatever.
(The ARM question is kinda immaterial, but I'm curious)
Mac people, for a few years now.