随笔分类 -  golang

摘要:参考链接: https://www.cnblogs.com/X-knight/p/10753833.html https://blog.csdn.net/weixin_33966365/article/details/89039190 Bolt是一个纯粹Key/Value模型的程序。该项目的目标是为 阅读全文
posted @ 2021-09-23 16:12 salami_china 阅读(74) 评论(0) 推荐(0)
摘要:git 仓库:https://github.com/hpcloud/tail.git package main import ( "fmt" "github.com/hpcloud/tail" "strings" ) type InfoData struct { InIntf string OutI 阅读全文
posted @ 2021-08-25 16:20 salami_china 阅读(101) 评论(0) 推荐(0)
摘要:原文链接:https://gobyexample.com/http-servers package main import ( "fmt" "net/http" ) func hello(w http.ResponseWriter, req *http.Request) { fmt.Fprintf( 阅读全文
posted @ 2021-08-20 15:08 salami_china 阅读(39) 评论(0) 推荐(0)
摘要:参考链接:https://www.cnblogs.com/-wenli/p/12304379.html Go语言中type的用法: 定义结构体类型 类型别名 定义接口类型 定义函数类型 1.定义结构体类型 结构体可用于用户自定义数据类型和进行面向对象编程。 type Person struct { 阅读全文
posted @ 2021-08-19 16:13 salami_china 阅读(111) 评论(0) 推荐(0)
摘要:参考链接:https://studygolang.com/articles/13389 switch sExpr { case expr1: some instructions case expr2: some other instructions case expr3: some other in 阅读全文
posted @ 2021-08-19 12:17 salami_china 阅读(98) 评论(0) 推荐(0)
摘要:参考链接:http://dockone.io/article/10681 查看内存使用情况: $ gops memstats 3739 alloc: 1.15MB (1205272 bytes) total-alloc: 1.15MB (1205272 bytes) sys: 69.45MB (72 阅读全文
posted @ 2021-08-17 17:35 salami_china 阅读(759) 评论(0) 推荐(0)
摘要:Ticker 是一个定时触发的计时器,它会以一个间隔 (interval) 往 channel 发送一个事件(当前时间),而 channel 的接收者可以以固定的时间间隔从 channel 中读取事件。 Demo 示例: package main import ( "fmt" "time" ) fu 阅读全文
posted @ 2021-07-21 14:52 salami_china 阅读(136) 评论(0) 推荐(0)
摘要:# Linux / macOS export GOPROXY=https://goproxy.io # Windows $env:GOPROXY = "https://goproxy.io" 参考链接:https://blog.csdn.net/sinat_38068807/article/deta 阅读全文
posted @ 2021-07-02 13:54 salami_china 阅读(253) 评论(0) 推荐(0)
摘要:问题:build constraints exclude all Go files in 解决:export GOOS="linux" 参考链接:https://www.h5w3.com/102231.html 阅读全文
posted @ 2021-07-01 18:46 salami_china 阅读(12597) 评论(0) 推荐(0)
摘要:原文链接:https://www.kancloud.cn/digest/batu-go/153538 bytes.buffer是一个缓冲byte类型的缓冲器存放着都是byteBuffer 是 bytes 包中的一个 type Buffer struct{…} A buffer is a variab 阅读全文
posted @ 2021-02-02 15:28 salami_china 阅读(248) 评论(0) 推荐(0)
摘要:原文链接:https://medium.com/@kevinbai/golang-%E4%B8%AD-string-%E4%B8%8E-byte-%E4%BA%92%E8%BD%AC%E4%BC%98%E5%8C%96-6651feb4e1f2 func StrToBytes(s string) [ 阅读全文
posted @ 2021-02-02 15:22 salami_china 阅读(232) 评论(0) 推荐(0)
摘要:func RemoveDuplicateElement(stringList []string) []string { result := make([]string, 0, len(stringList)) temp := map[string]struct{}{} for _, item := 阅读全文
posted @ 2021-02-02 13:09 salami_china 阅读(223) 评论(0) 推荐(0)
摘要:# vscode go linux 依赖包go get -v github.com/ramya-rao-a/go-outlinego get -v github.com/sqs/goreturnsgo get -u -v github.com/nsf/gocodego get -u -v githu 阅读全文
posted @ 2020-12-31 10:10 salami_china 阅读(177) 评论(0) 推荐(0)
摘要:问题: "https://proxy.golang.org/code.cloudfoundry.org/tlsconfig/@v/v0.0.0-20200131000646-bbe0f8da39b3.mod": dial tcp 216.58.200.49:443: i/o timeout 解决: 阅读全文
posted @ 2020-12-19 12:24 salami_china 阅读(212) 评论(0) 推荐(0)
摘要:原文链接:https://www.codenong.com/cs106100823/ package main import ( "fmt" "net" ) // 0: invalid ip // 4: IPv4 // 6: IPv6 func ParseIP(s string) (net.IP, 阅读全文
posted @ 2020-12-10 19:44 salami_china 阅读(1373) 评论(0) 推荐(0)
摘要:原文链接: https://studygolang.com/articles/11612 https://blog.csdn.net/yzf279533105/article/details/81238758 package main import ( "fmt" "strconv" "string 阅读全文
posted @ 2020-10-29 18:49 salami_china 阅读(990) 评论(0) 推荐(0)
摘要:参考链接: https://blog.csdn.net/huwh_/article/details/77879152?utm_source=blogxgwz3 https://baijiahao.baidu.com/s?id=1615101405775143768&wfr=spider&for=pc 阅读全文
posted @ 2020-08-11 11:11 salami_china 阅读(834) 评论(0) 推荐(0)
摘要:原文链接:https://www.cnblogs.com/believepd/p/10850679.html Package strings:https://golang.google.cn/pkg/strings/ package main import ( "fmt" "strconv" "st 阅读全文
posted @ 2020-07-30 09:30 salami_china 阅读(194) 评论(0) 推荐(0)
摘要:HasPrefix 判断字符串 s 是否以 prefix 开头:strings.HasPrefix(s, prefix string) bool HasSuffix 判断字符串 s 是否以 suffix 结尾:strings.HasSuffix(s, suffix string) bool 字符串包 阅读全文
posted @ 2020-07-20 14:46 salami_china 阅读(2019) 评论(0) 推荐(0)
摘要:参考资料:https://github.com/koding/multiconfig 测试代码: package main import ( "fmt" "github.com/koding/multiconfig" ) type Server struct { Demo DemoConfig } 阅读全文
posted @ 2020-07-20 11:48 salami_china 阅读(764) 评论(0) 推荐(0)