mirror of
				https://github.com/actions/setup-go.git
				synced 2025-10-31 16:13:43 +00:00 
			
		
		
		
	squash! Configure environment to avoid toolchain installs
Only modify env if `GOTOOLCHAIN` is not set
This commit is contained in:
		
							parent
							
								
									7252af563b
								
							
						
					
					
						commit
						277ab1eb0e
					
				
							
								
								
									
										17
									
								
								dist/setup/index.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										17
									
								
								dist/setup/index.js
									
									
									
									
										vendored
									
									
								
							| @ -94312,6 +94312,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) { | ||||
|     return (mod && mod.__esModule) ? mod : { "default": mod }; | ||||
| }; | ||||
| Object.defineProperty(exports, "__esModule", ({ value: true })); | ||||
| exports.GOTOOLCHAIN_LOCAL_VAL = exports.GOTOOLCHAIN_ENV_VAR = void 0; | ||||
| exports.getGo = getGo; | ||||
| exports.extractGoArchive = extractGoArchive; | ||||
| exports.getManifest = getManifest; | ||||
| @ -94330,6 +94331,8 @@ const sys = __importStar(__nccwpck_require__(5632)); | ||||
| const fs_1 = __importDefault(__nccwpck_require__(7147)); | ||||
| const os_1 = __importDefault(__nccwpck_require__(2037)); | ||||
| const utils_1 = __nccwpck_require__(1314); | ||||
| exports.GOTOOLCHAIN_ENV_VAR = 'GOTOOLCHAIN'; | ||||
| exports.GOTOOLCHAIN_LOCAL_VAL = 'local'; | ||||
| const MANIFEST_REPO_OWNER = 'actions'; | ||||
| const MANIFEST_REPO_NAME = 'go-versions'; | ||||
| const MANIFEST_REPO_BRANCH = 'main'; | ||||
| @ -94783,12 +94786,12 @@ const os_1 = __importDefault(__nccwpck_require__(2037)); | ||||
| function run() { | ||||
|     return __awaiter(this, void 0, void 0, function* () { | ||||
|         try { | ||||
|             setToolchain(); | ||||
|             //
 | ||||
|             // versionSpec is optional.  If supplied, install / use from the tool cache
 | ||||
|             // If not supplied then problem matchers will still be setup.  Useful for self-hosted.
 | ||||
|             //
 | ||||
|             const versionSpec = resolveVersionInput(); | ||||
|             setGoToolchain(); | ||||
|             const cache = core.getBooleanInput('cache'); | ||||
|             core.info(`Setup go version spec ${versionSpec}`); | ||||
|             let arch = core.getInput('architecture'); | ||||
| @ -94897,20 +94900,18 @@ function resolveVersionInput() { | ||||
|     } | ||||
|     return version; | ||||
| } | ||||
| function setToolchain() { | ||||
| function setGoToolchain() { | ||||
|     // docs: https://go.dev/doc/toolchain
 | ||||
|     // "local indicates the bundled Go toolchain (the one that shipped with the go command being run)"
 | ||||
|     // this is so any 'go' command is run with the selected Go version
 | ||||
|     // and doesn't trigger a toolchain download and run commands with that
 | ||||
|     // see e.g. issue #424
 | ||||
|     // and a similar discussion: https://github.com/docker-library/golang/issues/472
 | ||||
|     const toolchain = 'local'; | ||||
|     const toolchainVar = 'GOTOOLCHAIN'; | ||||
|     // set the value in process env so any `go` commands run as child-process
 | ||||
|     // and a similar discussion: https://github.com/docker-library/golang/issues/472.
 | ||||
|     // Set the value in process env so any `go` commands run as child-process
 | ||||
|     // don't cause toolchain downloads
 | ||||
|     process.env[toolchainVar] = toolchain; | ||||
|     process.env[installer.GOTOOLCHAIN_ENV_VAR] = installer.GOTOOLCHAIN_LOCAL_VAL; | ||||
|     // and in the runner env so e.g. a user running `go mod tidy` won't cause it
 | ||||
|     core.exportVariable(toolchainVar, toolchain); | ||||
|     core.exportVariable(installer.GOTOOLCHAIN_ENV_VAR, installer.GOTOOLCHAIN_LOCAL_VAL); | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
|  | ||||
| @ -8,6 +8,8 @@ import fs from 'fs'; | ||||
| import os from 'os'; | ||||
| import {StableReleaseAlias, isSelfHosted} from './utils'; | ||||
| 
 | ||||
| export const GOTOOLCHAIN_ENV_VAR = 'GOTOOLCHAIN'; | ||||
| export const GOTOOLCHAIN_LOCAL_VAL = 'local'; | ||||
| const MANIFEST_REPO_OWNER = 'actions'; | ||||
| const MANIFEST_REPO_NAME = 'go-versions'; | ||||
| const MANIFEST_REPO_BRANCH = 'main'; | ||||
|  | ||||
							
								
								
									
										18
									
								
								src/main.ts
									
									
									
									
									
								
							
							
						
						
									
										18
									
								
								src/main.ts
									
									
									
									
									
								
							| @ -11,12 +11,12 @@ import os from 'os'; | ||||
| 
 | ||||
| export async function run() { | ||||
|   try { | ||||
|     setToolchain(); | ||||
|     //
 | ||||
|     // versionSpec is optional.  If supplied, install / use from the tool cache
 | ||||
|     // If not supplied then problem matchers will still be setup.  Useful for self-hosted.
 | ||||
|     //
 | ||||
|     const versionSpec = resolveVersionInput(); | ||||
|     setGoToolchain(); | ||||
| 
 | ||||
|     const cache = core.getBooleanInput('cache'); | ||||
|     core.info(`Setup go version spec ${versionSpec}`); | ||||
| @ -162,19 +162,19 @@ function resolveVersionInput(): string { | ||||
|   return version; | ||||
| } | ||||
| 
 | ||||
| function setToolchain() { | ||||
| function setGoToolchain() { | ||||
|   // docs: https://go.dev/doc/toolchain
 | ||||
|   // "local indicates the bundled Go toolchain (the one that shipped with the go command being run)"
 | ||||
|   // this is so any 'go' command is run with the selected Go version
 | ||||
|   // and doesn't trigger a toolchain download and run commands with that
 | ||||
|   // see e.g. issue #424
 | ||||
|   // and a similar discussion: https://github.com/docker-library/golang/issues/472
 | ||||
|   const toolchain = 'local'; | ||||
|   const toolchainVar = 'GOTOOLCHAIN'; | ||||
| 
 | ||||
|   // set the value in process env so any `go` commands run as child-process
 | ||||
|   // and a similar discussion: https://github.com/docker-library/golang/issues/472.
 | ||||
|   // Set the value in process env so any `go` commands run as child-process
 | ||||
|   // don't cause toolchain downloads
 | ||||
|   process.env[toolchainVar] = toolchain; | ||||
|   process.env[installer.GOTOOLCHAIN_ENV_VAR] = installer.GOTOOLCHAIN_LOCAL_VAL; | ||||
|   // and in the runner env so e.g. a user running `go mod tidy` won't cause it
 | ||||
|   core.exportVariable(toolchainVar, toolchain); | ||||
|   core.exportVariable( | ||||
|     installer.GOTOOLCHAIN_ENV_VAR, | ||||
|     installer.GOTOOLCHAIN_LOCAL_VAL | ||||
|   ); | ||||
| } | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user