![]() ![]() Gofmt defines code formatting standards for Go and applies them to your code automatically. While it is valid Go, it produces unexpected results, ultimately printing: Super Mario %!s(int=3) This is warning us that we’re trying to interpolate an int into a string using the %s “format verb,” which isn’t usually intended for integers. main.go:6:2: Printf format %s has arg 3 of wrong type int ![]() go vet is part of a standard Go installation, making it straightforward to run from the command line.įmt.Printf("Super Mario %s\n",game_version)Īfter. One example of this is when you have unreachable code. It’s good at catching things where your code is technically valid but probably not working as intended. Go vet starts where the compiler ends by identifying subtle issues in your code. With that, let’s look a little more closely at each of these tools to see what they do. The higher rungs on the ladder are more focused on code aesthetics. Any code checking after that is optional. The top rung is golint(and other linters), which make code style recommendations (naming, code conventions, etc).Īt the bottom of the ladder, the Go compiler does a baseline check to ensure that your code is valid, catching things like syntax errors and missing imports. ![]() The third rung is gofmt, which applies standard formatting (whitespace, indentation, etc) The second rung is go vet, which finds subtle issues where your code may not work as intended. The bottom rung is GoCompiler, which finds serious errors that prevent your code from running. The ladder has four rungs, with the least opinionated at the bottom, and the most opinionated at the top. Popular options for code checking in Go can be thought of using the metaphor of a ladder to describe how opinionated they are. Detailed description of the image showing popular options for code checking in Go ![]()
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |