This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 1.//实现前导零出错:sn:="7DC3"+fmt.printf("%05d", uint16(rawdata[2])&0xFF+uint16(rawdata[1])) | |
| &:[fmt.Printf返回的是一个int和一个error,不能与string用+号一起操作] | |
| sn := fmt.Sprintf("%s%05d", "7DC3", uint16(rawdata[2])&0xFF+uint16(rawdata[1]))或fmt.Sprintf("7DC3%05d",uint16(rawdata[2])&0xFF+uint16(rawdata[1])) | |
| 2.//fmt.Sprint不能输出 | |
| &:根据fmt包API描述,fmt.Sprint是返回字符串,与fmt.Print的标准输出不同. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| go指针是什么? | |
| 定义 | |
| 所谓指针其实你可以把它想像成一个箭头,这个箭头指向(存储)一个变量的地址。 | |
| 因为这个箭头本身也需要变量来存储,所以也叫做指针变量。 | |
| 通过下面的例子可以看出指针地之间的关系。 | |
| package main | |
| 2 |