mirror of
https://github.com/actions/setup-go
synced 2024-12-22 06:12:42 +00:00
Use const declarations for variables that are never reassigned (#322)
This commit is contained in:
parent
21459d0b7b
commit
807559307d
4 changed files with 16 additions and 16 deletions
|
@ -155,7 +155,7 @@ steps:
|
||||||
```
|
```
|
||||||
## Getting go version from the go.mod file
|
## Getting go version from the go.mod file
|
||||||
|
|
||||||
The `go-version-file` input accepts a path to a `go.mod` file or a `go.work` file that contains the version of Go to be used by a project. As the `go.mod` file contains only major and minor (e.g. 1.18) tags, the action will search for the latest available patch version sequentially in the runner's directory with the cached tools, in the [version-manifest.json](https://github.com/actions/go-versions/blob/main/versions-manifest.json) file or at the go servers.
|
The `go-version-file` input accepts a path to a `go.mod` file or a `go.work` file that contains the version of Go to be used by a project. As the `go.mod` file contains only major and minor (e.g. 1.18) tags, the action will search for the latest available patch version sequentially in the runner's directory with the cached tools, in the [versions-manifest.json](https://github.com/actions/go-versions/blob/main/versions-manifest.json) file or at the go servers.
|
||||||
|
|
||||||
If both the `go-version` and the `go-version-file` inputs are provided then the `go-version` input is used.
|
If both the `go-version` and the `go-version-file` inputs are provided then the `go-version` input is used.
|
||||||
> The action will search for the `go.mod` file relative to the repository root
|
> The action will search for the `go.mod` file relative to the repository root
|
||||||
|
|
14
dist/setup/index.js
vendored
14
dist/setup/index.js
vendored
|
@ -63398,12 +63398,12 @@ function getInfoFromDist(versionSpec, arch) {
|
||||||
}
|
}
|
||||||
function findMatch(versionSpec, arch = os_1.default.arch()) {
|
function findMatch(versionSpec, arch = os_1.default.arch()) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
let archFilter = sys.getArch(arch);
|
const archFilter = sys.getArch(arch);
|
||||||
let platFilter = sys.getPlatform();
|
const platFilter = sys.getPlatform();
|
||||||
let result;
|
let result;
|
||||||
let match;
|
let match;
|
||||||
const dlUrl = 'https://golang.org/dl/?mode=json&include=all';
|
const dlUrl = 'https://golang.org/dl/?mode=json&include=all';
|
||||||
let candidates = yield module.exports.getVersionsDist(dlUrl);
|
const candidates = yield module.exports.getVersionsDist(dlUrl);
|
||||||
if (!candidates) {
|
if (!candidates) {
|
||||||
throw new Error(`golang download url did not return results`);
|
throw new Error(`golang download url did not return results`);
|
||||||
}
|
}
|
||||||
|
@ -63436,7 +63436,7 @@ exports.findMatch = findMatch;
|
||||||
function getVersionsDist(dlUrl) {
|
function getVersionsDist(dlUrl) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
// this returns versions descending so latest is first
|
// this returns versions descending so latest is first
|
||||||
let http = new httpm.HttpClient('setup-go', [], {
|
const http = new httpm.HttpClient('setup-go', [], {
|
||||||
allowRedirects: true,
|
allowRedirects: true,
|
||||||
maxRedirects: 3
|
maxRedirects: 3
|
||||||
});
|
});
|
||||||
|
@ -63484,7 +63484,7 @@ function resolveStableVersionDist(versionSpec, arch) {
|
||||||
let archFilter = sys.getArch(arch);
|
let archFilter = sys.getArch(arch);
|
||||||
let platFilter = sys.getPlatform();
|
let platFilter = sys.getPlatform();
|
||||||
const dlUrl = 'https://golang.org/dl/?mode=json&include=all';
|
const dlUrl = 'https://golang.org/dl/?mode=json&include=all';
|
||||||
let candidates = yield module.exports.getVersionsDist(dlUrl);
|
const candidates = yield module.exports.getVersionsDist(dlUrl);
|
||||||
if (!candidates) {
|
if (!candidates) {
|
||||||
throw new Error(`golang download url did not return results`);
|
throw new Error(`golang download url did not return results`);
|
||||||
}
|
}
|
||||||
|
@ -63611,8 +63611,8 @@ function run() {
|
||||||
const matchersPath = path_1.default.join(__dirname, '../..', 'matchers.json');
|
const matchersPath = path_1.default.join(__dirname, '../..', 'matchers.json');
|
||||||
core.info(`##[add-matcher]${matchersPath}`);
|
core.info(`##[add-matcher]${matchersPath}`);
|
||||||
// output the version actually being used
|
// output the version actually being used
|
||||||
let goPath = yield io.which('go');
|
const goPath = yield io.which('go');
|
||||||
let goVersion = (child_process_1.default.execSync(`${goPath} version`) || '').toString();
|
const goVersion = (child_process_1.default.execSync(`${goPath} version`) || '').toString();
|
||||||
core.info(goVersion);
|
core.info(goVersion);
|
||||||
core.setOutput('go-version', parseGoVersion(goVersion));
|
core.setOutput('go-version', parseGoVersion(goVersion));
|
||||||
core.startGroup('go env');
|
core.startGroup('go env');
|
||||||
|
|
|
@ -266,14 +266,14 @@ export async function findMatch(
|
||||||
versionSpec: string,
|
versionSpec: string,
|
||||||
arch = os.arch()
|
arch = os.arch()
|
||||||
): Promise<IGoVersion | undefined> {
|
): Promise<IGoVersion | undefined> {
|
||||||
let archFilter = sys.getArch(arch);
|
const archFilter = sys.getArch(arch);
|
||||||
let platFilter = sys.getPlatform();
|
const platFilter = sys.getPlatform();
|
||||||
|
|
||||||
let result: IGoVersion | undefined;
|
let result: IGoVersion | undefined;
|
||||||
let match: IGoVersion | undefined;
|
let match: IGoVersion | undefined;
|
||||||
|
|
||||||
const dlUrl: string = 'https://golang.org/dl/?mode=json&include=all';
|
const dlUrl = 'https://golang.org/dl/?mode=json&include=all';
|
||||||
let candidates: IGoVersion[] | null = await module.exports.getVersionsDist(
|
const candidates: IGoVersion[] | null = await module.exports.getVersionsDist(
|
||||||
dlUrl
|
dlUrl
|
||||||
);
|
);
|
||||||
if (!candidates) {
|
if (!candidates) {
|
||||||
|
@ -315,7 +315,7 @@ export async function getVersionsDist(
|
||||||
dlUrl: string
|
dlUrl: string
|
||||||
): Promise<IGoVersion[] | null> {
|
): Promise<IGoVersion[] | null> {
|
||||||
// this returns versions descending so latest is first
|
// this returns versions descending so latest is first
|
||||||
let http: httpm.HttpClient = new httpm.HttpClient('setup-go', [], {
|
const http: httpm.HttpClient = new httpm.HttpClient('setup-go', [], {
|
||||||
allowRedirects: true,
|
allowRedirects: true,
|
||||||
maxRedirects: 3
|
maxRedirects: 3
|
||||||
});
|
});
|
||||||
|
@ -372,7 +372,7 @@ async function resolveStableVersionDist(versionSpec: string, arch: string) {
|
||||||
let archFilter = sys.getArch(arch);
|
let archFilter = sys.getArch(arch);
|
||||||
let platFilter = sys.getPlatform();
|
let platFilter = sys.getPlatform();
|
||||||
const dlUrl: string = 'https://golang.org/dl/?mode=json&include=all';
|
const dlUrl: string = 'https://golang.org/dl/?mode=json&include=all';
|
||||||
let candidates: IGoVersion[] | null = await module.exports.getVersionsDist(
|
const candidates: IGoVersion[] | null = await module.exports.getVersionsDist(
|
||||||
dlUrl
|
dlUrl
|
||||||
);
|
);
|
||||||
if (!candidates) {
|
if (!candidates) {
|
||||||
|
|
|
@ -67,8 +67,8 @@ export async function run() {
|
||||||
core.info(`##[add-matcher]${matchersPath}`);
|
core.info(`##[add-matcher]${matchersPath}`);
|
||||||
|
|
||||||
// output the version actually being used
|
// output the version actually being used
|
||||||
let goPath = await io.which('go');
|
const goPath = await io.which('go');
|
||||||
let goVersion = (cp.execSync(`${goPath} version`) || '').toString();
|
const goVersion = (cp.execSync(`${goPath} version`) || '').toString();
|
||||||
core.info(goVersion);
|
core.info(goVersion);
|
||||||
|
|
||||||
core.setOutput('go-version', parseGoVersion(goVersion));
|
core.setOutput('go-version', parseGoVersion(goVersion));
|
||||||
|
|
Loading…
Reference in a new issue