Difference between revisions of "Go"
Jump to navigation
Jump to search
(13 intermediate revisions by 2 users not shown) | |||
Line 2: | Line 2: | ||
* [[Concurrent]] | * [[Concurrent]] | ||
+ | * [[Memory management]]: [[Garbage collection]] | ||
== Installation == | == Installation == | ||
* macOS: <code>[[brew install go]]</code> | * macOS: <code>[[brew install go]]</code> | ||
* [[Ubuntu]]: <code>[[apt install golang-go]]</code> (aprox 500MB) | * [[Ubuntu]]: <code>[[apt install golang-go]]</code> (aprox 500MB) | ||
+ | |||
+ | |||
+ | * [[Ubuntu VM]] on [[Apple M]]: | ||
+ | [[wget]] https://go.dev/dl/go1.20.3.linux-arm64.tar.gz | ||
+ | rm -rf [[/usr/local/]]go && tar -C /usr/local -xzf go1.20.3.linux-arm64.tar.gz && [[export]] [[PATH]]=$PATH:/usr/local/go/bin && [[go version]] | ||
== Commands == | == Commands == | ||
Line 13: | Line 19: | ||
* <code>[[go test]]</code>, for unit testing and microbenchmarks | * <code>[[go test]]</code>, for unit testing and microbenchmarks | ||
* <code>[[go fmt]]</code>, for formatting code | * <code>[[go fmt]]</code>, for formatting code | ||
− | * <code>[[go get]]</code>, for retrieving and installing remote packages | + | * <code>[[go get]]</code>, for retrieving and installing remote [[packages]] |
* <code>[[go vet]]</code>, a static analyzer looking for potential errors in code | * <code>[[go vet]]</code>, a static analyzer looking for potential errors in code | ||
* <code>[[go run]]</code>, a shortcut for building and executing code | * <code>[[go run]]</code>, a shortcut for building and executing code | ||
Line 21: | Line 27: | ||
* <code>[[go mod]] init</code> | * <code>[[go mod]] init</code> | ||
* <code>[[go list]]</code> | * <code>[[go list]]</code> | ||
+ | * [[go tool]] | ||
+ | ** [[go tool pprof]] | ||
== Examples == | == Examples == | ||
Line 33: | Line 41: | ||
* [[GVisor]] (2018) | * [[GVisor]] (2018) | ||
* [[Grafana]] (2014) | * [[Grafana]] (2014) | ||
+ | |||
+ | == Errors == | ||
+ | * <code>[[panic: runtime error: invalid memory address or nil pointer dereference]]</code> | ||
== Related == | == Related == | ||
* [[Class Inheritance]]: [[embedding]] and [[interfaces]] ([[duck typing]]) | * [[Class Inheritance]]: [[embedding]] and [[interfaces]] ([[duck typing]]) | ||
− | * [[net/http]] | + | * <code>[[net/http]]</code> |
− | * [[channels]] | + | * <code>[[channels]]</code> |
* https://pkg.go.dev/std | * https://pkg.go.dev/std | ||
* <code>[[defer]]</code> | * <code>[[defer]]</code> | ||
* <code>[[$HOME/go/bin/]]</code> | * <code>[[$HOME/go/bin/]]</code> | ||
+ | * [[Concurrency vs parallelism]] | ||
== See also == | == See also == | ||
* https://en.wikipedia.org/wiki/Go_(programming_language)#Version_history | * https://en.wikipedia.org/wiki/Go_(programming_language)#Version_history | ||
+ | * {{go tool}} | ||
* {{Go}} | * {{Go}} | ||
[[Category:Programming]] | [[Category:Programming]] | ||
[[Category:Go]] | [[Category:Go]] |
Latest revision as of 09:09, 8 August 2024
wikipedia:Go (programming language) (Nov 2009)
Installation[edit]
- macOS:
brew install go
- Ubuntu:
apt install golang-go
(aprox 500MB)
wget https://go.dev/dl/go1.20.3.linux-arm64.tar.gz rm -rf /usr/local/go && tar -C /usr/local -xzf go1.20.3.linux-arm64.tar.gz && export PATH=$PATH:/usr/local/go/bin && go version
Commands[edit]
go help
go build
, which builds Go binaries using only information in the source files themselves, no separate makefilesgo install
go test
, for unit testing and microbenchmarksgo fmt
, for formatting codego get
, for retrieving and installing remote packagesgo vet
, a static analyzer looking for potential errors in codego run
, a shortcut for building and executing codegodoc
, for displaying documentation or serving it via HTTPgorename
, for renaming variables, functions, and so on in a type-safe waygo generate
, a standard way to invoke code generatorsgo mod init
go list
- go tool
Examples[edit]
Activities[edit]
- Read go FAQs: https://go.dev/doc/faq#goroutines
Projects[edit]
- Kubernetes (2014)
- GVisor (2018)
- Grafana (2014)
Errors[edit]
Related[edit]
- Class Inheritance: embedding and interfaces (duck typing)
net/http
channels
- https://pkg.go.dev/std
defer
$HOME/go/bin/
- Concurrency vs parallelism
See also[edit]
- https://en.wikipedia.org/wiki/Go_(programming_language)#Version_history
- go tool, pprof
- Go, Gorutine:
go [ mod
|list
|fmt
,for
|build
|get
|version
|env | install | test
]go help
, Go template, Echo go web framework, Go packages, Blank identifier
Advertising: