mirror of
https://github.com/actions/setup-go.git
synced 2025-06-30 21:23:43 +00:00
Sync branch 'modules-caching' with 'actions/setup-go/main'
This commit is contained in:
commit
eedb42bbf8
11 changed files with 131 additions and 65 deletions
12
src/main.ts
12
src/main.ts
|
@ -56,6 +56,8 @@ export async function run() {
|
|||
let goVersion = (cp.execSync(`${goPath} version`) || '').toString();
|
||||
core.info(goVersion);
|
||||
|
||||
core.setOutput('go-version', parseGoVersion(goVersion));
|
||||
|
||||
core.startGroup('go env');
|
||||
let goEnv = (cp.execSync(`${goPath} env`) || '').toString();
|
||||
core.info(goEnv);
|
||||
|
@ -75,7 +77,7 @@ export async function addBinToPath(): Promise<boolean> {
|
|||
}
|
||||
|
||||
let buf = cp.execSync('go env GOPATH');
|
||||
if (buf) {
|
||||
if (buf.length > 1) {
|
||||
let gp = buf.toString().trim();
|
||||
core.debug(`go env GOPATH :${gp}:`);
|
||||
if (!fs.existsSync(gp)) {
|
||||
|
@ -95,3 +97,11 @@ export async function addBinToPath(): Promise<boolean> {
|
|||
}
|
||||
return added;
|
||||
}
|
||||
|
||||
export function parseGoVersion(versionString: string): string {
|
||||
// get the installed version as an Action output
|
||||
// based on go/src/cmd/go/internal/version/version.go:
|
||||
// fmt.Printf("go version %s %s/%s\n", runtime.Version(), runtime.GOOS, runtime.GOARCH)
|
||||
// expecting go<version> for runtime.Version()
|
||||
return versionString.split(' ')[2].slice('go'.length);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue