Skip to content

Instantly share code, notes, and snippets.

@StuartsHome
Last active March 29, 2021 14:27
Show Gist options
  • Save StuartsHome/d4ba8b885f00d6792c85c8812003c57c to your computer and use it in GitHub Desktop.
Save StuartsHome/d4ba8b885f00d6792c85c8812003c57c to your computer and use it in GitHub Desktop.
Create Executable:
- $ go build <filename>.go
Create Binaries and executables:
- $ go install <filename>.go
Run file:
- $ go run <filename>.go
Run multiple file:
- $ go run <filename>.go <filename>.go
Run all files:
- $ go run *.go
Add mod file (makes the current directory the root of a module):
- $ go mod init <filename>.go
Clean unused dependencies:
- $ go mod tidy
Fetch package:
- $ go get -u <url>
Install tools in VScode:
- from command palette:
- go install tools
Testify:
Run tests:
- go test ./... -v
Asterisk
- * attached to a type (*string) indicates a pointer to the type.
- * attached to a variable in an assignment (*v = ...) indicates an indirect assignment.
That is, change the value pointed at by the variable.
- * attached to a variable or expression (*v) indicates a pointer dereference.
That is, take the value the variable is pointing at.
- & attached to a variable or expression (&v) indicates a reference.
That is, create a pointer to the value of the variable or to the field.
Packages:
Testify:
- $ go get github.com/stretchr/testify
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment