1. 21

    My 2 cents. The other day, I wanted to test a new feature of Hugo that has not been released:

    https://github.com/gohugoio/hugo/pull/6771

    Hugo doesnt have a CI, so the only option was building it myself. This might not sound like a big deal, but I am on Windows. On Windows, you typically have problems building projects as the developers many times dont even test on Windows. This will lead to compile and dependency errors.

    Hugo is a big project, the Zip file is 12 MB, so I was pretty sure I would have some trouble with this. But I didnt. I just followed the instruction:

    git clone git://github.com/gohugoio/hugo
    cd hugo
    go install
    

    and it took a while, but not a single error. I have built many projects with C, C++, C#, D, Nim and others over the years, and this is the first time I have had this experience with this large of a project. The closest to this I think is FFmpeg, but even with that you needed to install dependencies else something would be missing from the output or simply fail. I had a similar experience with Rust, where I needed a new build:

    https://github.com/getzola/zola/issues/893

    except Rust just failed spectacularly, because it seems one of the dependency crates uses C on the backend, and has poor or no support for Windows:

    https://github.com/compass-rs/sass-rs/issues/63

    Go lets me get work done. I can focus on the code, where with other languages, I find myself getting distracted with the tooling or build process.

    1. 15

      Every time I write code in a language other than Go, I’m startled by how weak the tooling is. After writing all Go for about two years at a job, I switched to a place that has almost exclusively Python projects. To say that I miss go fmt is the king of all understatements. Also, after Go, I don’t see why every programming language doesn’t just come up with a native way of running tests a là go test. It’s weird to have a series of codebases where the command to execute their test suites is only the same because it’s placed behind a standardized make target.

      1. 15

        Maybe it’s just the ecosystems I play in, but it appears that language tooling is converging on this pattern though.

        Rust:

        • cargo fmt
        • cargo test

        DotNet:

        • dotnet format
        • dotnet test

        Elixir:

        • mix format
        • mix test
        1. 11

          Zig, too:

          • zig fmt
          • zig [build] test
          1. 2

            That’s awesome, thank you for your response! I know about prettier for Javascript (and to their credit, it really makes absolutely no sense to have a formalized code formatter for a language with no official interpreter). I also knew about cargo (slipped my mind), but am firmly outside the .NET/Elixir ecosystems, so glad to see that happening.

            1. 7

              There’s also pyfmt for python, and pytest. I think pytest came before go, though.

          2. 5

            Black (https://github.com/psf/black) is the Python equivalent of go fmt.

        1. 1

          Note you can do this too:

          package main
          func main() {
             println("sun mon tue")
          }
          

          https://golang.org/pkg/builtin#println

          1. 5

            I’m aware, but IIRC that builtin is something that’s not guaranteed to be in future releases of Go. I want to teach people forward-compatible Go as much as possible.

            1. 3

              I think fmt makes for a really great introduction to the notion of “importing” code, as it provides functionality even non-programmers can appreciate, and is just as built-in as println. I don’t see how getting rid of the import would necessarily speed up the user’s first code writing experience, or impart upon them a greater understanding.

            1. 2

              I’m taking a pre-existing code base, and running a suite of tools that will create a separate codebase that, when executed, will yield the input codebase.

              1. 59

                go fmt is the kind of hero every language deserves.

                1. 3

                  For those who don’t know about it: The go fmt equivalent for Java is Google Java Format.

                  1. 3

                    Would just like to mention Prettier here, in case anyone is writing JavaScript / TypeScript and doesn’t know about it.

                    This has become such an important point for me, I almost consider languages without a tool like this unusable.

                    1. 7

                      I think Go takes it a step further by disallowing configuration (unlike Prettier). Much like type systems eliminate a class of errors, go fmt eliminates a class of bickering.

                      1. 5

                        You should check out black for Python, it’s really nice and builds on the same ideals.

                        1. 1

                          disallowing configuration (unlike Prettier).

                          That’s one reason I like Standard JS.

                          1. 1

                            Absolutely true, and I wish they’d just straight up remove the option. Still, I’m glad it works without configuration, and stubbornness is punished with extra dotfile clutter in your repo that is entirely on you.

                        2. 1

                          mix format for Elixir code. Same philosophy too, I believe. No more arguments about formatting.

                        1. 5

                          There’s a library called Jennifer that is useful for generating Go code. This week, I’m working on a tool that will read a given Go file and spit out the relevant Jennifer code to recreate the input code. Like a messed-up quine.