github.com/nozzle/golangci-lint@v1.49.0-nz3/test/testdata/nosprintfhostport.go (about) 1 //golangcitest:args -Enosprintfhostport 2 package testdata 3 4 import ( 5 "fmt" 6 "net" 7 ) 8 9 func _() { 10 11 _ = fmt.Sprintf("postgres://%s:%s@127.0.0.1/%s", "foo", "bar", "baz") 12 13 _ = fmt.Sprintf("http://api.%s/foo", "example.com") 14 15 _ = fmt.Sprintf("http://api.%s:6443/foo", "example.com") 16 17 _ = fmt.Sprintf("http://%s/foo", net.JoinHostPort("foo", "80")) 18 19 _ = fmt.Sprintf("9invalidscheme://%s:%d", "myHost", 70) 20 21 _ = fmt.Sprintf("gopher://%s/foo", net.JoinHostPort("foo", "80")) 22 23 _ = fmt.Sprintf("telnet+ssl://%s/foo", net.JoinHostPort("foo", "80")) 24 25 _ = fmt.Sprintf("http://%s/foo:bar", net.JoinHostPort("foo", "80")) 26 27 _ = fmt.Sprintf("http://user:password@%s/foo:bar", net.JoinHostPort("foo", "80")) 28 29 _ = fmt.Sprintf("http://example.com:9211") 30 31 _ = fmt.Sprintf("gopher://%s:%d", "myHost", 70) // want "host:port in url should be constructed with net.JoinHostPort and not directly with fmt.Sprintf" 32 33 _ = fmt.Sprintf("telnet+ssl://%s:%d", "myHost", 23) // want "host:port in url should be constructed with net.JoinHostPort and not directly with fmt.Sprintf" 34 35 _ = fmt.Sprintf("weird3.6://%s:%d", "myHost", 23) // want "host:port in url should be constructed with net.JoinHostPort and not directly with fmt.Sprintf" 36 37 _ = fmt.Sprintf("https://user@%s:%d", "myHost", 8443) // want "host:port in url should be constructed with net.JoinHostPort and not directly with fmt.Sprintf" 38 39 _ = fmt.Sprintf("postgres://%s:%s@%s:5050/%s", "foo", "bar", "baz", "qux") // want "host:port in url should be constructed with net.JoinHostPort and not directly with fmt.Sprintf" 40 41 _ = fmt.Sprintf("https://%s:%d", "myHost", 8443) // want "host:port in url should be constructed with net.JoinHostPort and not directly with fmt.Sprintf" 42 43 _ = fmt.Sprintf("https://%s:9211", "myHost") // want "host:port in url should be constructed with net.JoinHostPort and not directly with fmt.Sprintf" 44 45 ip := "fd00::1" 46 _ = fmt.Sprintf("http://%s:1936/healthz", ip) // want "host:port in url should be constructed with net.JoinHostPort and not directly with fmt.Sprintf" 47 }