随笔分类 - Go
摘要:要支持任一类型的值,该单个函数将需要一种方法来声明它支持的类型。另一方面,调用代码需要一种方法来指定它是使用整数映射还是浮点映射。 package main import "fmt" func main() { // Initialize a map for the integer values i
阅读全文
摘要:代码 package main import ( "errors" "net/http" "strings" "time" "github.com/gin-gonic/gin" "github.com/golang-jwt/jwt" ) func main() { // gin.Default 会使
阅读全文
摘要:package main import ( "fmt" "reflect" "strings" ) type Student struct { Name string Age int Addr string } // 遍历结构体, 只遍历,不做修改 func forStruct_1() { s :=
阅读全文
摘要:package main import ( "fmt" "runtime" "sync" "time" ) func main() { ch := make(chan int, runtime.NumCPU()) // 定义一个有缓冲的channel wg := sync.WaitGroup{} f
阅读全文
摘要:1. github地址 2. 安装方式 docker 部署 docker build -t x/file_server . docker run -p 8080:8080 -itd x/file_server app 部署 go build -o app . ./app 打开浏览器访问 localh
阅读全文
摘要:package main import ( "fmt" "sort" ) type SortByGszzl []map[string]string // 设置自定义类型 // 一个内置的排序算法需要知道三个东西: // 1.序列的长度, Len // 2.表示两个元素比较的结果,Less // 3.
阅读全文
摘要:package main import ( "fmt" "log" "gopkg.in/yaml.v2" ) func test_parse_yaml() { data := []byte(` name: GOLANG say: f: hello b: world say2: - f: hello
阅读全文
摘要:package main import ( "encoding/json" "fmt" "log" ) var json_data = []byte(` { "name" : "Golang", "say" : ["Hello", "World!"] } `) type Data struct {
阅读全文

浙公网安备 33010602011771号