v := a; if t { v = b }
Sadly, this doesn't work well if a is a function call :-( v := a; if t { v = b }
Sadly, this doesn't work well if a is a function call :-(go fmt may not be anyone's favorite code style, but having go fmt is so much better than dealing with everyone else's favorite (incompatible!) styles.
It has no switches to disable features.
It destroys many nice single-line constructs, e.g.
if err != nil { return err }
Much of my code would be painful to read without that one.On the bright side, it artificially inflates your line count, so you appear more productive!
The ecosystem-wide consistency of go fmt is its biggest strength. Adding switches to disable features would eliminate that.
I've put a lot of thought into my style guide, and anyone who hasn't done the same has no useful insight on whether go fmt is a help or a hindrance.
Is it more powerful in some way than the auto-formatters that exist for nearly every other language?
Edit: I didn't mean this as an insult, I meant it as a genuine question. I don't know much about the Go ecosystem, and I meant to find out what Go's killer feature is in 2019, when other languages now have strong and elegant concurrency, C-like performance with higher-level syntax and without manual memory management, etc.
But from my experience with Java, Go, and Python, I find Go a very versatile programming language. Being able to compile binaries means it's great for infrastructure deployments and CLI tools. Goroutines, concurrency, and etc make it a great choice for server/micro service use cases as well. Some can say that not having a JVM is a plus as well.
However, developers do have to be disciplined with error handling and dependency management. But one can argue that this is the case for software development in general.
IMO, the fundamental advantages of Go over competing languages in the long run are its fast compile time and its combination of native code+garbage collection.
I do not like Go the language but I can begrudgingly admire the ecosystem
I find myself choosing Go for:
- concurrency - memory footprint management - cpu speed - that nebulous feeling I want a program etched in stone (strongly typed)
I've written a lot of Api based clients. Read from a queue and update AWS permissions. Receive a callout from something and passing it along to somewhere else. Come to think of it, I've written a lot of queue-reading workers, some replaced existing Ruby workers for CPU or concurrency reasons.
I think in the space of having computers talk to computers Go is highly successful because it handles nearly everything with the standard library. So I find a lot of sdk's for specific platforms written in go that can get something going with the standard library and a single package for the platform.
Of course, this is not as good for having fun programming, unless the programmer feels having written something is more fun than writing it.
Fast compilation speed, easy integration with C, and the "one large static binary" are probably my favourite features, although I do wish those binary sizes weren't quite so large...