Skip to content

Commit 8fee112

Browse files
authored
Merge pull request #225 from thaJeztah/drop_go1.8
registryurl: remove fallback code for go < 1.8
2 parents 0e5dbc6 + 70f4765 commit 8fee112

File tree

4 files changed

+18
-62
lines changed

4 files changed

+18
-62
lines changed

osxkeychain/osxkeychain_darwin.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ func (h Osxkeychain) List() (map[string]string, error) {
138138
listLen = int(listLenC)
139139
pathTmp := (*[1 << 30]*C.char)(unsafe.Pointer(pathsC))[:listLen:listLen]
140140
acctTmp := (*[1 << 30]*C.char)(unsafe.Pointer(acctsC))[:listLen:listLen]
141-
//taking the array of c strings into go while ignoring all the stuff irrelevant to credentials-helper
141+
// taking the array of c strings into go while ignoring all the stuff irrelevant to credentials-helper
142142
resp := make(map[string]string)
143143
for i := 0; i < listLen; i++ {
144144
if C.GoString(pathTmp[i]) == "0" {
@@ -160,7 +160,7 @@ func splitServer(serverURL string) (*C.struct_Server, error) {
160160
proto = C.kSecProtocolTypeHTTP
161161
}
162162
var port int
163-
p := registryurl.GetPort(u)
163+
p := u.Port()
164164
if p != "" {
165165
port, err = strconv.Atoi(p)
166166
if err != nil {
@@ -170,7 +170,7 @@ func splitServer(serverURL string) (*C.struct_Server, error) {
170170

171171
return &C.struct_Server{
172172
proto: C.SecProtocolType(proto),
173-
host: C.CString(registryurl.GetHostname(u)),
173+
host: C.CString(u.Hostname()),
174174
port: C.uint(port),
175175
path: C.CString(u.Path),
176176
}, nil

registryurl/parse.go

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,24 @@ func Parse(registryURL string) (*url.URL, error) {
2828
return nil, errors.New("unsupported scheme: " + u.Scheme)
2929
}
3030

31-
if GetHostname(u) == "" {
31+
if u.Hostname() == "" {
3232
return nil, errors.New("no hostname in URL")
3333
}
3434

3535
u.RawQuery = ""
3636
return u, nil
3737
}
38+
39+
// GetHostname returns the hostname of the URL
40+
//
41+
// Deprecated: use url.Hostname()
42+
func GetHostname(u *url.URL) string {
43+
return u.Hostname()
44+
}
45+
46+
// GetPort returns the port number of the URL
47+
//
48+
// Deprecated: use url.Port()
49+
func GetPort(u *url.URL) string {
50+
return u.Port()
51+
}

registryurl/url_go18.go

Lines changed: 0 additions & 17 deletions
This file was deleted.

registryurl/url_non_go18.go

Lines changed: 0 additions & 41 deletions
This file was deleted.

0 commit comments

Comments
 (0)