1. 首页
  2. 文章

学习记录

wangchao71 ·

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

本文来自:简书

感谢作者:wangchao71

查看原文:学习记录

程序员网址导航:https://www.hrefs.cn/ 了解一下~~~
#1

用户登录

没有账号?注册

今日阅读排行

    加载中

一周阅读排行

    加载中