Basic Struture of a Go file
- first program and file structure
go mod init **modele path**
initialized a go.mod file which Discribes the module: name/module path go version the module path is also the import path
Package All our code must belong to a package the first ststement in Go file must be
package main
the main is the standard name of the main application file
func main(){
}
is the entry point of our Go program
import "github.com/AdamsGeeky/"
module path can correspond to a repository you plant to publish your module to (that is github/AdamsGeeky/)
The basic structure of a Go file typically includes:
Package declaration: This specifies the package that the file belongs to.
Import statements: These import any necessary packages that are needed for the file.
Constants: Any constants that are used in the file are typically defined at the beginning.
Variables: Any variables that are used in the file are typically defined next.
Functions: Any functions that are used in the file are typically defined after the variables.
Main function: The main function is the entry point of a Go program and is typically the last thing defined in the file.