学习记录
wangchao71 · · 1147 次点击 · · 开始浏览2019年03月02日
golang:
1. strings
string.Replace(s, " ", "%20", -1)
string.Split
string.SplitN: 最终分成N份
string.SplitAfter: 保留sep
strings.Join
len([]rune(s))
2. switch type
switch x := m.(type) {
case bool, int: // x's type is as m, usually interface
}
3. struct
type Param map[string]interface{}
type Show struct{Param}
这样是ok的,但是map需要单独make
type People struct {
name string `json:"name"`
}
小写的变量没法被外部访问,也不要加json,因为没法marshal
有疑问加站长微信联系(非本文作者)
入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889
关注微信- 请尽量让自己的回复能够对别人有帮助
- 支持 Markdown 格式, **粗体**、~~删除线~~、
`单行代码` - 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
- 图片支持拖拽、截图粘贴等方式上传
收入到我管理的专栏 新建专栏
2019年03月02日
golang:
1. strings
string.Replace(s, " ", "%20", -1)
string.Split
string.SplitN: 最终分成N份
string.SplitAfter: 保留sep
strings.Join
len([]rune(s))
2. switch type
switch x := m.(type) {
case bool, int: // x's type is as m, usually interface
}
3. struct
type Param map[string]interface{}
type Show struct{Param}
这样是ok的,但是map需要单独make
type People struct {
name string `json:"name"`
}
小写的变量没法被外部访问,也不要加json,因为没法marshal