Prerequisites
-
Go (tested on
go 1.24 linux/amd64). Installation instructions here. -
Prepare the required libraries by running this command from the root dir of this repository:
go mod downloadThis command will download all packages as defined in go.mod and go.sum.
This go module follows the Golang project layout as specified in golang-standards/project-layout.
macaron
├── golang
│ ├── cmd
│ │ ├── bashparser
│ │ └── cuevalidator
│ ├── internal
│ │ ├── bashparser
│ │ ├── cuevalidator
│ │ └── filewriter
│ └── README.md
├── go.mod
├── go.sum
└── <other files in the root repository ...>golangis the directory where all Go source files and tests are located. This is to separate it frompythonwhere the code for Macaron sit.- The
cmddir contains the main applications of the module. The applications usually don't have a lot of code. These applications will import and use code frominternalorpkg. - The
internaldir contains the internal code that we don't want others importing. This is also enforced by Go itself - check here for more information. - The
pkgdir contains code that we want to share with anyone who use our go module. They can import those libraries so we should expect code in this directory to work properly. This dir is empty at the moment. go.modandgo.sumcontain the metadata (checksum, semantic versions, etc.) of required libraries, the name of the Go module and the Go version.
To run an application (in the cmd dir), from the root dir of this repository:
go run ./golang/cmd/<app_name>/<app_name>.go [ARGS]To run all the tests, from the root dir of this repository:
make testTo just run the Go tests:
go test ./golang/...To run the tests and record the code coverage, from the root dir of this repository:
go test -cover ./golang/...To build an executable of an application in this module:
make setup-goAlternatively you can run:
go build ./golang/cmd/<app_name>/<app_name>.goThis will generate an executable app_name in the current directory. We can also change the path of the output executable by using:
go build -o <output_path> ./golang/cmd/<app_name>/<app_name>.go