Skip to content

Commit 6755e49

Browse files
aviaustapelberg
authored andcommitted
support comma-separated paths in Go-Import-Path (#75)
Some packages can be imported from several import paths. XS-Go-Import-Path can reflect this by using a comma-separated list of known import paths for the package. This patch updates make.go's existing package detection mechanism to support this. The pkgs struct field ImportPath is renamed to XSGoImportPath to avoid confusion because it could be that XSGoImportPath is not a valid import path if it contains commas. For example, the following format would now be valid: ``` XS-Go-Import-Path: github.com/go-mgo/mgo, gopkg.in/mgo.v2, labix.org/v2/mgo, launchpad.net/mgo ```
1 parent 33dedc7 commit 6755e49

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

search.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ func getGolangBinaries() (map[string]string, error) {
2626
return nil, fmt.Errorf("unexpected HTTP status code: got %d, want %d", got, want)
2727
}
2828
var pkgs []struct {
29-
Binary string `json:"binary"`
30-
ImportPath string `json:"metadata_value"`
31-
Source string `json:"source"`
29+
Binary string `json:"binary"`
30+
XSGoImportPath string `json:"metadata_value"`
31+
Source string `json:"source"`
3232
}
3333
if err := json.NewDecoder(resp.Body).Decode(&pkgs); err != nil {
3434
return nil, err
@@ -37,7 +37,10 @@ func getGolangBinaries() (map[string]string, error) {
3737
if !strings.HasSuffix(pkg.Binary, "-dev") {
3838
continue // skip -dbgsym packages etc.
3939
}
40-
golangBinaries[pkg.ImportPath] = pkg.Binary
40+
for _, importPath := range strings.Split(pkg.XSGoImportPath, ",") {
41+
// XS-Go-Import-Path can be comma-separated and contain spaces.
42+
golangBinaries[strings.TrimSpace(importPath)] = pkg.Binary
43+
}
4144
}
4245
return golangBinaries, nil
4346
}

0 commit comments

Comments
 (0)