Building multiple Go files

If a program is split into multiple files, you can pass all of them to the build command. For example, if you have a main.go file and an utility.go file containing extra functions, you could build them by running the following command:

go build main.go utility.go

If you tried to build main.go by itself, it would not be able to find the references to the functions in utility.go.

Get Security with Go now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.