During our module discussion, we discussed some go commands related to go modules, let's now discuss some other important commands.
Starting with go fmt
, which formats the source code and it's enforced by that language so that we can focus on how our code should work rather than how our code should look.
$ go fmt
This might seem a little weird at first especially if you're coming from a javascript or python background like me but frankly, it's quite nice not to worry about linting rules.
Next, we have go vet
which reports likely mistakes in our packages.
So, if I go ahead and make a mistake in the syntax, and then run go vet
.
It should notify me of the errors.
$ go vet
Next, we have go env
which simply prints all the go environment information, we'll learn about some of these build-time variable later.
Lastly, we have, go doc
which shows documentation for package or symbol, here's an example of the format package.
$ go doc -src fmt Printf
Let's use go help
command to see what other commands are available.
$ go help
As we can see, we have:
go fix
finds Go programs that use old APIs and rewrites them to use newer ones.
go generate
is usually used for code generation.
go install
compiles and install packages and dependencies.
go clean
is used for cleaning files that are generated by compilers.
Some other very important commands are go build
and go test
but we will learn about them in detail later in the course.
This article is part of my open source Go Course available on Github.
karanpratapsingh / learn-go
Master the fundamentals and advanced features of the Go programming language
Learn Go
Hey, welcome to the course, and thanks for learning Go. I hope this course provides a great learning experience.
This course is also available on my website and as an ebook on leanpub. Please leave a ⭐ as motivation if this was helpful!
Table of contents
-
Getting Started
-
Chapter I
-
Chapter II
-
Chapter III
-
Chapter IV
-
Appendix
What is Go?
Go (also known as Golang) is a programming language developed at Google in 2007 and open-sourced in 2009.
It focuses on simplicity, reliability, and efficiency. It was designed to combine the efficacy, speed…
Top comments (0)