|
| 1 | +//args: -Egosprintfhostport |
| 2 | +package testdata |
| 3 | + |
| 4 | +import ( |
| 5 | + "fmt" |
| 6 | + "net" |
| 7 | +) |
| 8 | + |
| 9 | +func _() { |
| 10 | + _ = fmt.Sprintf("gopher://%s/foo", net.JoinHostPort("foo", "80")) |
| 11 | + |
| 12 | + _ = fmt. Sprintf( "postgres://%s:%[email protected]/%s", "foo", "bar", "baz") |
| 13 | + |
| 14 | + _ = fmt.Sprintf("http://%s/foo", net.JoinHostPort("foo", "80")) |
| 15 | + |
| 16 | + _ = fmt.Sprintf("http://api.%s:6443/foo", "example.com") |
| 17 | + |
| 18 | + _ = fmt.Sprintf("http://api.%s/foo", "example.com") |
| 19 | + |
| 20 | + _ = fmt.Sprintf("telnet+ssl://%s/foo", net.JoinHostPort("foo", "80")) |
| 21 | + |
| 22 | + _ = fmt.Sprintf("http://%s/foo:bar", net.JoinHostPort("foo", "80")) |
| 23 | + |
| 24 | + _ = fmt.Sprintf("http://user:password@%s/foo:bar", net.JoinHostPort("foo", "80")) |
| 25 | + |
| 26 | + _ = fmt.Sprintf("http://example.com:9211") |
| 27 | + |
| 28 | + _ = fmt.Sprintf("gopher://%s:%d", "myHost", 70) // ERROR "host:port in url should be constructed with net.JoinHostPort and not directly with fmt.Sprintf" |
| 29 | + |
| 30 | + _ = fmt.Sprintf("telnet+ssl://%s:%d", "myHost", 23) // ERROR "host:port in url should be constructed with net.JoinHostPort and not directly with fmt.Sprintf" |
| 31 | + |
| 32 | + _ = fmt.Sprintf("https://user@%s:%d", "myHost", 8443) // ERROR "host:port in url should be constructed with net.JoinHostPort and not directly with fmt.Sprintf" |
| 33 | + |
| 34 | + _ = fmt.Sprintf("postgres://%s:%s@%s:5050/%s", "foo", "bar", "baz", "qux") // ERROR "host:port in url should be constructed with net.JoinHostPort and not directly with fmt.Sprintf" |
| 35 | + |
| 36 | + _ = fmt.Sprintf("https://%s:%d", "myHost", 8443) // ERROR "host:port in url should be constructed with net.JoinHostPort and not directly with fmt.Sprintf" |
| 37 | + |
| 38 | + _ = fmt.Sprintf("https://%s:9211", "myHost") // ERROR "host:port in url should be constructed with net.JoinHostPort and not directly with fmt.Sprintf" |
| 39 | + |
| 40 | + ip := "fd00::1" |
| 41 | + _ = fmt.Sprintf("http://%s:1936/healthz", ip) // ERROR "host:port in url should be constructed with net.JoinHostPort and not directly with fmt.Sprintf" |
| 42 | +} |
0 commit comments