惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

罗磊的独立博客
Cisco Talos Blog
Cisco Talos Blog
C
Check Point Blog
博客园_首页
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Martin Fowler
Martin Fowler
Recorded Future
Recorded Future
S
Security @ Cisco Blogs
L
LINUX DO - 最新话题
博客园 - 司徒正美
P
Privacy International News Feed
G
Google Developers Blog
I
Intezer
Hacker News - Newest:
Hacker News - Newest: "LLM"
博客园 - 聂微东
The GitHub Blog
The GitHub Blog
C
Cybersecurity and Infrastructure Security Agency CISA
www.infosecurity-magazine.com
www.infosecurity-magazine.com
Scott Helme
Scott Helme
K
Kaspersky official blog
I
InfoQ
Y
Y Combinator Blog
T
The Blog of Author Tim Ferriss
Webroot Blog
Webroot Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
大猫的无限游戏
大猫的无限游戏
D
Docker
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
W
WeLiveSecurity
Microsoft Azure Blog
Microsoft Azure Blog
Spread Privacy
Spread Privacy
量子位
H
Hacker News: Front Page
Simon Willison's Weblog
Simon Willison's Weblog
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
SecWiki News
SecWiki News
S
Security Affairs
Latest news
Latest news
人人都是产品经理
人人都是产品经理
C
CERT Recently Published Vulnerability Notes
S
Security Archives - TechRepublic
V
Visual Studio Blog
T
Troy Hunt's Blog
S
Secure Thoughts
F
Fortinet All Blogs
V
V2EX
The Register - Security
The Register - Security
J
Java Code Geeks
MongoDB | Blog
MongoDB | Blog
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO

博客园 - 天纯蓝

GO语言最主的特性 解决“Comparison method violates its general contract!” Centos7 Mysql5.7主从服务器配置 maven buid 导出项目依赖的jar包问题 [数据库]漫谈ElasticSearch关于ES性能调优几件必须知道的事(转) MongoDB 聚合管道(Aggregation Pipeline) mongodb分布式查询 MongoDB JAVA API Filters mongodb.conf配置文件详解 mongodb安装配置 Elasticsearch-2.3.x填坑之路 CentOS VMware 下SSH配置方法详解 15个nosql数据库 MySql 优化 Elasticsearch 相关名词理解 - 天纯蓝 Elasticsearch集群中处理大型日志流的几个常用概念 - 天纯蓝 ES配置文件参考与参数详解 - 天纯蓝 Java连接Elasticsearch集群 Linux下Tomcat的启动、关闭、杀死进程
go错误总结(27条)
天纯蓝 · 2022-03-16 · via 博客园 - 天纯蓝

1、undefined: apppen

没有此方法,请检查语法或者单词是否正确

2、m3 redeclared in this block previous declaration at .\utils.go:308:2

此方法或者变量没有使用,具体在308行

3、missing return at end of function

此方法缺少return返回或者结束标识符

4、s6 declared but not used

s6变量没有使用

5、err declared but not used b declared but not used

err和b没有使用

6、Println call has possible formatting directive %T

Println 调用的格式指令存在问题

7、exported function GmyFunc should have comment or be unexported

声明你写的代码不符合规范

8、(func(a, b int) int literal) (value of type func(a int, b int) int) is not used

此函数没有被调用

9、死锁与 goroutine 泄露

检查:goroutine 栈图定位死锁函数方法

解决方法:严禁在一行代码内对同一个变量产生两次写行为;严禁在一行代码内对同一个变量产生既写又读的行为; 严禁在锁内执行被锁对象的行为函数。

10、sync.Pool

sync.Pool 的本质是用来减轻 gc 负担 ;将它当做一个对象缓冲池并不合适:对象何时释放,用户是无法释放的。
虽然 sync.Pool 把对象存入其缓冲池时可以做到无锁,但是取值的时候可能碰到锁竞争的问题 ;所以可能对性能提升并没有多大帮助。

11、expected ‘IDENT’, found 'func’

错误:

func oper(a, b int, func func(int, int) int) int {
}
1
2
解决:

func oper(a, b int, fun func(int, int) int) int {
}
1
2
12、Println arg fun is a func value, not called

fun是一个func值,未调用

13、golang.org/x/crypto is not in your go.mod fil

cd $gopath/src/ 如果没有golang/x 创建mkdir -p golang/x,然后cd golang/x
使用git进行下载 git clone https://github.com/golang/crypto.git
也可以:git clone --depth=1 https://github.com/golang/xxx.git

14、Println formats using the default formats for its operands and writes to standard output. Spaces are always added between operands and a newline is appended. It returns the number of bytes written and any write error encountered.

Println格式使用其操作数的默认格式,并写入标准输出。操作数之间总是加上空格,并追加换行符。它返回写入的字节数和遇到的任何写入错误

15、illegal character U+FF0C ','

标点符号错误

16、exported type Userinfo should have comment or be unexported

没有使用Userinfo结构体

17、sql: expected 0 arguments, got 1

会报无效字符

18、too many arguments compiler

编译器参数太多

19、expected ‘package’, found 'const’

请检查代码依赖或者mod.go是否错误

20、possible misuse of unsafe.Pointerunsafeptr

指针存储不安全

21、首字母大写是公有的 Echo,首字母小写是私有的 echo

22、 don’t use underscores in Go names; var w_content should be wContent

不符合命名规范

23、ReadLine is a low-level line-reading primitive. Most callers should use ReadBytes(’\n’) or ReadString(’\n’) instead or use a Scanner. ReadLine tries to return a single line, not including the end-of-line bytes. If the line was too long for the buffer then isPrefix is set and the beginning of the line is returned. The rest of the line will be returned from future calls. isPrefix will be false when returning the last fragment of the line. The returned buffer is only valid until the next call to ReadLine. ReadLine either returns a non-nil line or it returns an error, never both. The text returned from ReadLine does not include the line end ("\r\n" or “\n”). No indication or error is given if the input ends without a final line end. Calling UnreadByte after ReadLine will always unread the last byte read (possibly a character belonging to the line end) even if that byte is not part of the line returned by ReadLine.

解决:

line, err := buf.ReadLine('\n') 改成 line, err := buf.ReadString('\n') 或者 line, err := buf.ReadBytes('\n')

24、内部有缓冲区的读取 goroutine 很昂贵

解决:

netpoll(epoll,kqueue); 重用缓冲区。

25、内部有缓冲区的写入 goroutine 很昂贵

解决:

必要时启动 goroutine; 重用缓冲区。

26、随着大量的连接,netpoll 不起作用

解决:

重复使用 goroutines 并限制其数量

27、net/http不是处理升级到WebSocket的最快方法

解决: