GoLang - hpepper/henpep-dev-tools GitHub Wiki
Go lang
Introduction
Purpose
References
Installation
Overview
write a project
- mkdir my_server
- cd my_server
- go mod init my_server
- vi my_server.go
- go mod tidy
Run project
- go run .
Syntax
Basic syntax
- single line comment:
// - block comment:
/* */
Structures
Bytes
Files
JSON
Scratch pad notes
Tools
RabbitMQ
Networking
TCP
Websocket
To use it:
- Add
"github.com/gorilla/websocket"to the codesimport()section - run: go mod init example.com/m/v2
- go mod tidy
and now you can build.
protobuf
- go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
- add
option go_package = "./mypkgname";to the .proto file - protoc -I=. --go_out=. ./my.api.proto
- go mod tidy