@@ -51,25 +51,7 @@ class GolangPackageManager: PackageManagerProtocol {
51
51
let gobinPath = packagePath. appending ( path: " bin " , directoryHint: . isDirectory) . path
52
52
var goInstallCommand = [ " env " , " GOBIN= \( gobinPath) " , " go " , " install " ]
53
53
54
- if let gitRef = source. gitReference, let repoUrl = source. repositoryUrl {
55
- // Check if this is a Git-based package
56
- var packageName = source. name
57
- if !packageName. contains ( " github.com " ) && !packageName. contains ( " golang.org " ) {
58
- packageName = repoUrl. replacingOccurrences ( of: " https:// " , with: " " )
59
- }
60
-
61
- var gitVersion : String
62
- switch gitRef {
63
- case . tag( let tag) :
64
- gitVersion = tag
65
- case . revision( let rev) :
66
- gitVersion = rev
67
- }
68
-
69
- goInstallCommand. append ( " \( packageName) @ \( gitVersion) " )
70
- } else {
71
- goInstallCommand. append ( " \( source. name) @ \( source. version) " )
72
- }
54
+ goInstallCommand. append ( getGoInstallCommand ( source) )
73
55
_ = try await executeInDirectory ( in: packagePath. path, goInstallCommand)
74
56
75
57
// If there's a subpath, build the binary
@@ -152,4 +134,26 @@ class GolangPackageManager: PackageManagerProtocol {
152
134
line. contains ( dependencyPath)
153
135
}
154
136
}
137
+
138
+ private func getGoInstallCommand( _ source: PackageSource ) -> String {
139
+ if let gitRef = source. gitReference, let repoUrl = source. repositoryUrl {
140
+ // Check if this is a Git-based package
141
+ var packageName = source. name
142
+ if !packageName. contains ( " github.com " ) && !packageName. contains ( " golang.org " ) {
143
+ packageName = repoUrl. replacingOccurrences ( of: " https:// " , with: " " )
144
+ }
145
+
146
+ var gitVersion : String
147
+ switch gitRef {
148
+ case . tag( let tag) :
149
+ gitVersion = tag
150
+ case . revision( let rev) :
151
+ gitVersion = rev
152
+ }
153
+
154
+ return " \( packageName) @ \( gitVersion) "
155
+ } else {
156
+ return " \( source. name) @ \( source. version) "
157
+ }
158
+ }
155
159
}
0 commit comments