Memo of Golang Part 1

本文是 Golang 编程备忘录的第一部分,主要总结了Go语言中的一些常用知识点,包括注释和错误消息约定、strings.Builder、strconv.Itoa、map迭代、正则分割、自定义类型等。强调了使用strings.Builder提高字符串连接效率,以及在处理错误消息时的规范。同时介绍了math.Hypot函数和iota在常量定义中的应用,以及unicode和utf8包的功能。
摘要由CSDN通过智能技术生成

Memo of Golang Part 1

Based on Go v1.15

In the recent practice of Golang, there’re many trivial knowledges that worthy to be memorized in daily coding. So I came up with the idea to have this series basicly for my own memorization. if it helps anyone else, it would be great.

Comments and error messages convention

The convention has been defined in Effective Go, but there’re something that might be hard to notice.

  • A comment for packages or functions, etc should be ended with a period. Using such punctuations increases the readablity of comments.

        //Repeat returns a string that repeats given string N times.
    
  • An error message shouldn’t have the initial letter upper case unless there’s certain acronym and use any ending punctuation.

        errors.New("oops, there're something wrong
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值