Added golang note
This commit is contained in:
parent
aa6568149b
commit
48e1760230
31
memo/golang.md
Normal file
31
memo/golang.md
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
# Golang basics
|
||||||
|
## Initialize project
|
||||||
|
```bash
|
||||||
|
$ go mod init <project-name> #usually folder name
|
||||||
|
```
|
||||||
|
|
||||||
|
## Insert package
|
||||||
|
```go
|
||||||
|
package main
|
||||||
|
|
||||||
|
import "fmt"
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
// your code here
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Running code
|
||||||
|
```bash
|
||||||
|
$ go run main.go
|
||||||
|
```
|
||||||
|
|
||||||
|
## Pointer in Go
|
||||||
|
```go
|
||||||
|
var userName string
|
||||||
|
var userTickets int
|
||||||
|
|
||||||
|
fmt.Scan(&userName)
|
||||||
|
// &userName point to the memory of the var
|
||||||
|
```
|
||||||
|
|
||||||
Loading…
x
Reference in New Issue
Block a user