@@ -1279,6 +1279,8 @@ const core = __importStar(__webpack_require__(470));
12791279const tc = __importStar ( __webpack_require__ ( 533 ) ) ;
12801280const installer = __importStar ( __webpack_require__ ( 749 ) ) ;
12811281const path = __importStar ( __webpack_require__ ( 622 ) ) ;
1282+ const cp = __importStar ( __webpack_require__ ( 129 ) ) ;
1283+ const fs = __importStar ( __webpack_require__ ( 747 ) ) ;
12821284function run ( ) {
12831285 return __awaiter ( this , void 0 , void 0 , function * ( ) {
12841286 try {
@@ -1291,6 +1293,8 @@ function run() {
12911293 // since getting unstable versions should be explicit
12921294 let stable = ( core . getInput ( 'stable' ) || 'true' ) . toUpperCase ( ) === 'TRUE' ;
12931295 console . log ( `Setup go ${ stable ? 'stable' : '' } version spec ${ versionSpec } ` ) ;
1296+ // if there's a globally install go and bin path, prefer that
1297+ let addedBin = addBinToPath ( ) ;
12941298 if ( versionSpec ) {
12951299 let installDir = tc . find ( 'go' , versionSpec ) ;
12961300 if ( ! installDir ) {
@@ -1302,6 +1306,11 @@ function run() {
13021306 core . exportVariable ( 'GOROOT' , installDir ) ;
13031307 core . addPath ( path . join ( installDir , 'bin' ) ) ;
13041308 console . log ( 'Added go to the path' ) ;
1309+ // if the global installed bin wasn't added,
1310+ // we can add the bin just installed
1311+ if ( ! addBinToPath ) {
1312+ addBinToPath ( ) ;
1313+ }
13051314 }
13061315 else {
13071316 throw new Error ( `Could not find a version that satisfied version spec: ${ versionSpec } ` ) ;
@@ -1317,6 +1326,19 @@ function run() {
13171326 } ) ;
13181327}
13191328exports . run = run ;
1329+ function addBinToPath ( ) {
1330+ let added = false ;
1331+ let buf = cp . execSync ( 'go env GOPATH' ) ;
1332+ if ( buf ) {
1333+ let d = buf . toString ( ) . trim ( ) ;
1334+ let bp = path . join ( d , 'bin' ) ;
1335+ if ( fs . existsSync ( bp ) ) {
1336+ core . addPath ( bp ) ;
1337+ added = true ;
1338+ }
1339+ }
1340+ return added ;
1341+ }
13201342
13211343
13221344/***/ } ) ,
@@ -4576,14 +4598,11 @@ var __importStar = (this && this.__importStar) || function (mod) {
45764598} ;
45774599Object . defineProperty ( exports , "__esModule" , { value : true } ) ;
45784600const tc = __importStar ( __webpack_require__ ( 533 ) ) ;
4579- const cm = __importStar ( __webpack_require__ ( 470 ) ) ;
45804601const path = __importStar ( __webpack_require__ ( 622 ) ) ;
45814602const semver = __importStar ( __webpack_require__ ( 280 ) ) ;
45824603const httpm = __importStar ( __webpack_require__ ( 539 ) ) ;
45834604const sys = __importStar ( __webpack_require__ ( 737 ) ) ;
45844605const core_1 = __webpack_require__ ( 470 ) ;
4585- const cp = __importStar ( __webpack_require__ ( 129 ) ) ;
4586- const fs = __importStar ( __webpack_require__ ( 747 ) ) ;
45874606function downloadGo ( versionSpec , stable ) {
45884607 return __awaiter ( this , void 0 , void 0 , function * ( ) {
45894608 let toolPath ;
@@ -4605,7 +4624,6 @@ function downloadGo(versionSpec, stable) {
46054624 // extracts with a root folder that matches the fileName downloaded
46064625 const toolRoot = path . join ( extPath , 'go' ) ;
46074626 toolPath = yield tc . cacheDir ( toolRoot , 'go' , makeSemver ( match . version ) ) ;
4608- addBinToPath ( ) ;
46094627 }
46104628 }
46114629 catch ( error ) {
@@ -4615,19 +4633,6 @@ function downloadGo(versionSpec, stable) {
46154633 } ) ;
46164634}
46174635exports . downloadGo = downloadGo ;
4618- function addBinToPath ( ) {
4619- return __awaiter ( this , void 0 , void 0 , function * ( ) {
4620- let buf = cp . execSync ( 'go env GOPATH' ) ;
4621- if ( buf ) {
4622- let d = buf . toString ( ) . trim ( ) ;
4623- let bp = path . join ( d , 'bin' ) ;
4624- if ( fs . existsSync ( bp ) ) {
4625- cm . addPath ( bp ) ;
4626- }
4627- }
4628- } ) ;
4629- }
4630- exports . addBinToPath = addBinToPath ;
46314636function findMatch ( versionSpec , stable ) {
46324637 return __awaiter ( this , void 0 , void 0 , function * ( ) {
46334638 let archFilter = sys . getArch ( ) ;
0 commit comments