@@ -61770,7 +61770,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
61770
61770
return (mod && mod.__esModule) ? mod : { "default": mod };
61771
61771
};
61772
61772
Object.defineProperty(exports, "__esModule", ({ value: true }));
61773
- exports.parseGoVersion = exports.addBinToPath = exports.run = void 0;
61773
+ exports.convertEnvStringToJson = exports. parseGoVersion = exports.addBinToPath = exports.run = void 0;
61774
61774
const core = __importStar(__nccwpck_require__(2186));
61775
61775
const io = __importStar(__nccwpck_require__(7436));
61776
61776
const installer = __importStar(__nccwpck_require__(2574));
@@ -61818,11 +61818,19 @@ function run() {
61818
61818
core.debug(`add bin ${added}`);
61819
61819
const goPath = yield io.which('go');
61820
61820
const goVersion = (child_process_1.default.execSync(`${goPath} version`) || '').toString();
61821
+ const goEnv = (child_process_1.default.execSync(`${goPath} env`) || '').toString();
61822
+ const goEnvJson = JSON.parse(convertEnvStringToJson(goEnv));
61823
+ const parsedGoVersion = parseGoVersion(goVersion);
61824
+ // Go versions less that 1.16 do not have the GOVERSION environment variable
61825
+ if (semver.lt(parsedGoVersion, '1.16.0')) {
61826
+ goEnvJson['GOVERSION'] = 'go' + parsedGoVersion;
61827
+ }
61828
+ core.info(goVersion);
61821
61829
if (cache && cache_utils_1.isCacheFeatureAvailable()) {
61822
61830
const packageManager = 'default';
61823
61831
const cacheDependencyPath = core.getInput('cache-dependency-path');
61824
61832
try {
61825
- yield cache_restore_1.restoreCache(parseGoVersion(goVersion) , packageManager, cacheDependencyPath);
61833
+ yield cache_restore_1.restoreCache(parsedGoVersion , packageManager, cacheDependencyPath);
61826
61834
}
61827
61835
catch (error) {
61828
61836
core.warning(`Restore cache failed: ${error.message}`);
@@ -61831,11 +61839,12 @@ function run() {
61831
61839
// add problem matchers
61832
61840
const matchersPath = path_1.default.join(__dirname, '../..', 'matchers.json');
61833
61841
core.info(`##[add-matcher]${matchersPath}`);
61834
- // output the version actually being used
61835
- core.info(goVersion);
61836
- core.setOutput('go-version', parseGoVersion(goVersion));
61842
+ core.setOutput('go-version', parsedGoVersion);
61843
+ core.setOutput('go-path', goEnvJson['GOPATH']);
61844
+ core.setOutput('go-cache', goEnvJson['GOCACHE']);
61845
+ core.setOutput('go-mod-cache', goEnvJson['GOMODCACHE']);
61846
+ core.setOutput('go-env', goEnvJson);
61837
61847
core.startGroup('go env');
61838
- const goEnv = (child_process_1.default.execSync(`${goPath} env`) || '').toString();
61839
61848
core.info(goEnv);
61840
61849
core.endGroup();
61841
61850
}
@@ -61883,6 +61892,16 @@ function parseGoVersion(versionString) {
61883
61892
return versionString.split(' ')[2].slice('go'.length);
61884
61893
}
61885
61894
exports.parseGoVersion = parseGoVersion;
61895
+ function convertEnvStringToJson(envString) {
61896
+ const envArray = envString.split('\n');
61897
+ const envObject = {};
61898
+ envArray.forEach(envVar => {
61899
+ const [key, value] = envVar.split(/=(?=")/);
61900
+ envObject[key] = value === null || value === void 0 ? void 0 : value.replace(/"/g, '');
61901
+ });
61902
+ return JSON.stringify(envObject);
61903
+ }
61904
+ exports.convertEnvStringToJson = convertEnvStringToJson;
61886
61905
function resolveVersionInput() {
61887
61906
let version = core.getInput('go-version');
61888
61907
const versionFilePath = core.getInput('go-version-file');
0 commit comments