試圖構建一個運行http服務器的go程序的靜態鏈接版本,并使用net包來確定和解析傳入請求的IP地址。使用此構建語句:CGO_ENABLED=0 go install -a -ldflags '-s' .我的程序中的這個序言: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 一起構建,生成靜態鏈接程序,但不適用于 go 1.4.2。構建成功,但程序不是靜態鏈接的。在源代碼中:// 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}唯一的區別似乎是substr和the Unicode code points in chars。我寫了一些測試來測試它們。他們的行為似乎是相同的。我不明白什么時候使用哪個。
- 1 回答
- 0 關注
- 1482 瀏覽
添加回答
舉報
0/150
提交
取消