Skip to content
Henry m edited this page Oct 4, 2023 · 13 revisions

Go lang

Introduction

Purpose

References

Installation

Overview

write a project

  1. mkdir my_server
  2. cd my_server
  3. go mod init my_server
  4. vi my_server.go
  5. go mod tidy

Run project

  • go run .

Syntax

Basic syntax

  • single line comment: //
  • block comment: /* */

Structures

Bytes

Files

JSON

Scratch pad notes

  • multi threads :
  • IPC :
  • sleep -

Tools

RabbitMQ

Networking

  • DNS

TCP

Websocket

    • documentation -

To use it:

  1. Add "github.com/gorilla/websocket" to the codes import() section
  2. run: go mod init example.com/m/v2
  3. go mod tidy

and now you can build.

protobuf

  1. go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
  2. add option go_package = "./mypkgname"; to the .proto file
  3. protoc -I=. --go_out=. ./my.api.proto
  4. go mod tidy

WebRTC