initial
This commit is contained in:
commit
74ae93a96e
1 changed files with 94691 additions and 0 deletions
36
joplin notion extension/Web Development/Go/Initial.md
Normal file
36
joplin notion extension/Web Development/Go/Initial.md
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
Initial
|
||||
|
||||
Install go compiler.
|
||||
|
||||
Sample program
|
||||
```go
|
||||
|
||||
// file name : main.go
|
||||
package main
|
||||
import ("fmt")
|
||||
|
||||
func main() {
|
||||
fmt.Println("Hello World!")
|
||||
}
|
||||
```
|
||||
then run `go run main.go` or `go build -o main main.go && ./main`.
|
||||
for partilcular platform
|
||||
`GOOS=linux GOARCH=arm64 go build -o myapp-linux-arm64 . `
|
||||
and equivalent of `npm i`
|
||||
to install all packages
|
||||
`go get .` or `go mod tidy`
|
||||
to install specific package
|
||||
`go get github.com/spf13/cobra@latest`
|
||||
to remove go package
|
||||
simply remove import statements and then run `go mod tidy`
|
||||
|
||||
for initiating like `npm init -y`
|
||||
use `go mod init <module_name>`
|
||||
|
||||
|
||||
Program explanation
|
||||
1. in go every program is part of package that's why here is ths package main
|
||||
2. fmt package is imported
|
||||
3. main function
|
||||
4. fmt.Println is used to print text
|
||||
5. Comments are like in C ie `//` for single line and `/* */` for multi line
|
||||
Loading…
Reference in a new issue