June 2017
Beginner
1091 pages
22h 9m
English
So far in the book, you have learned how to create and bundle Go code as reusable packages. A package, however, cannot be executed as a standalone program. To create a program (also known as a command), you take a package and define an entry point of execution as follows:
mainmain() to be used as the entry point of the programThe function main takes no argument nor returns any value. The following shows the abbreviated source code for the main package used in the Ohm's Law example (from earlier). It uses the package flag, from Go's standard library, to parse program arguments formatted as flag:
package main import ( "flag" "fmt" ...
Read now
Unlock full access