Difference between revisions of "Go"

From wikieduonline
Jump to navigation Jump to search
 
(50 intermediate revisions by 4 users not shown)
Line 1: Line 1:
[[wikipedia:Go (programming language)]] (2009)
+
[[wikipedia:Go (programming language)]] (Nov [[2009]])
  
* [[concurrent]]
+
* [[Concurrent]]
 +
* [[Memory management]]: [[Garbage collection]]
  
brew install go
+
== Installation ==
 +
* macOS: <code>[[brew install go]]</code>
 +
* [[Ubuntu]]: <code>[[apt install golang-go]]</code> (aprox 500MB)
  
== Tools ==
 
* <code>go build</code>, which builds Go binaries using only information in the source files themselves, no separate makefiles
 
* <code>go test</code>, for unit testing and microbenchmarks
 
* <code>go fmt</code>, for formatting code
 
* <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 run</code>, a shortcut for building and executing code
 
* <code>godoc</code>, for displaying documentation or serving it via HTTP
 
* <code>gorename</code>, for renaming variables, functions, and so on in a type-safe way
 
* <code>go generate</code>, a standard way to invoke code generators
 
  
==Hello world==
+
* [[Ubuntu VM]] on [[Apple M]]:
<pre>
+
[[wget]] https://go.dev/dl/go1.20.3.linux-arm64.tar.gz
package main
+
  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]]
  
import "fmt"
+
== Commands ==
 +
* <code>[[go help]]</code>
 +
* <code>[[go build]]</code>, which builds Go binaries using only information in the source files themselves, no separate makefiles
 +
* <code>[[go install]]</code>
 +
* <code>[[go test]]</code>, for unit testing and microbenchmarks
 +
* <code>[[go fmt]]</code>, for formatting code
 +
* <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 run]]</code>, a shortcut for building and executing code
 +
* <code>[[godoc]]</code>, for displaying documentation or serving it via HTTP
 +
* <code>[[gorename]]</code>, for renaming variables, functions, and so on in a type-safe way
 +
* <code>[[go generate]]</code>, a standard way to invoke code generators
 +
* <code>[[go mod]] init</code>
 +
* <code>[[go list]]</code>
 +
* [[go tool]]
 +
** [[go tool pprof]]
  
func main() {
+
== Examples ==
    fmt.Println("Hello, world!")
+
* [[Go: Hello world! example]]
}
+
* [[for (Go lang)]]
</pre>
 
  
where "[[fmt]]" is the package for ''formatted [[Input/output|I/O]]'', similar to C's [[C file input/output]].<ref>{{Cite web|url=https://golang.org/pkg/fmt/|title=fmt - The Go Programming Language|website=golang.org|access-date=2019-04-08}}</ref>
+
== Activities ==
 +
* Read go FAQs: https://go.dev/doc/faq#goroutines
  
 +
== Projects ==
 +
* [[Kubernetes]] (2014)
 +
* [[GVisor]] (2018)
 +
* [[Grafana]] (2014)
  
 +
== Errors ==
 +
* <code>[[panic: runtime error: invalid memory address or nil pointer dereference]]</code>
  
 +
== Related ==
 +
* [[Class Inheritance]]: [[embedding]] and [[interfaces]] ([[duck typing]])
 +
* <code>[[net/http]]</code>
 +
* <code>[[channels]]</code>
 +
* https://pkg.go.dev/std
 +
* <code>[[defer]]</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}}
* {{C}}
 
 
  
 
[[Category:Programming]]
 
[[Category:Programming]]
 +
[[Category:Go]]

Latest revision as of 09:09, 8 August 2024

wikipedia:Go (programming language) (Nov 2009)

Installation[edit]


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]

Examples[edit]

Activities[edit]

Projects[edit]

Errors[edit]

Related[edit]

See also[edit]

Advertising: