試圖構(gòu)建一個(gè)運(yùn)行http服務(wù)器的go程序的靜態(tài)鏈接版本,并使用net包來確定和解析傳入請求的IP地址。使用此構(gòu)建語句:CGO_ENABLED=0 go install -a -ldflags '-s' .我的程序中的這個(gè)序言:package mainimport ( "encoding/json" "errors" "fmt" "log" "net" "net/http" "path/filepath" "strings" "golang.org/x/blog/content/context/userip" "github.com/oschwald/maxminddb-golang")這與 go 1.3 一起構(gòu)建,生成靜態(tài)鏈接程序,但不適用于 go 1.4.2。構(gòu)建成功,但程序不是靜態(tài)鏈接的。在源代碼中:// Contains returns true if substr is within s.func Contains(s, substr string) bool { return Index(s, substr) >= 0}// ContainsAny returns true if any Unicode code points in chars are within s.func ContainsAny(s, chars string) bool { return IndexAny(s, chars) >= 0}唯一的區(qū)別似乎是substr和the Unicode code points in chars。我寫了一些測試來測試它們。他們的行為似乎是相同的。我不明白什么時(shí)候使用哪個(gè)。
1 回答

拉丁的傳說
TA貢獻(xiàn)1789條經(jīng)驗(yàn) 獲得超8個(gè)贊
我認(rèn)為兩個(gè)功能是完全不同的。包含用于檢測字符串是否包含子字符串。ContainsAny 用于檢測字符串是否包含提供的字符串中的任何字符。
- 1 回答
- 0 關(guān)注
- 1454 瀏覽
添加回答
舉報(bào)
0/150
提交
取消