package main import ( "fmt" "strings" ) func main() { //比较首位字符的序号是否比后面首位字符大,如果不大就为-1 //如果首位俩个相同,会继续比较第二位的序号 fmt.Println(strings.Compare("a",&quo...
package main import ( "fmt" "strings" ) func main() { //去掉头和尾的空格 fmt.Println(strings.TrimSpace(" aa bb cc ")) //aa bb cc //去掉前缀 fmt.Prin...
package main import ( "fmt" "strings" ) func main() { //整个字符串,以什么为分隔符,进行拆分 aa := strings.Split("i love you"," ") fmt.Println(aa,len(aa...
package main import ( "fmt" "strings" ) func main() { //用爱心进行拼接 a1 := strings.Join([]string{"i","love","you"},"❤") ...
打开和关闭文件/*简易方式打开一个文件,拿着一顿骚操作,一秒后关闭.以只读方式打开一个文件,创建其带缓冲的读取器,读取文件到末尾.使用ioutil包对test.txt进行简易读取.以创写追加或创写覆盖方法打开一个文件,缓冲式写出几行数据,倒干缓冲区后退出。使用os包的状态检测结合,os.ISnotExist(err)判断文件师父存在.使用ioutil包进行简易文件写出. */简单打开一个文件...
服务器端:package main import ( "net" "fmt" "os" ) func ServerHandleError(err error,when string) { if err != nil { fmt.Println(err, "net.Lis...
get请求package mainimport ( "fmt" "io/ioutil" "net/http" "os")func main() { resp, err := http.Get("https://baike.baidu.com/item/书/130176?fr=aladdin&quo...
package main import ( "fmt" "io/ioutil" "net/http" "regexp" "strconv" "sync" "time" ) var ( C...
package main import ( "fmt" "io/ioutil" "net/http" "regexp" "strconv" "time" ) var ( //<img src="ht...
package main import ( "fmt" "io/ioutil" "net/http" "os" "regexp" ) var ( //3-30625-1970-04-26-0474 //reLink = `[1-6]\...