Skip to content

Commit 07386de

Browse files
committed
fix: 1.21 provides a new go.env file
Signed-off-by: Maxime Soulé <btik-git@scoubidou.com>
1 parent 6d63a7d commit 07386de

2 files changed

Lines changed: 24 additions & 8 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ jobs:
6060
steps:
6161
- name: Setup go
6262
run: |
63-
curl -sL https://raw.githubusercontent.com/maxatome/install-go/v3.4/install-go.pl |
63+
curl -sL https://raw.githubusercontent.com/maxatome/install-go/v3.5/install-go.pl |
6464
perl - ${{ matrix.go-version }} $HOME/go
6565
6666
- name: Checkout code

install-go.pl

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@
9595
exit 0;
9696
}
9797

98-
$TARGET = '1.18.x';
98+
$TARGET = '1.20.x';
9999
$TIP = 1;
100100
}
101101

@@ -224,10 +224,11 @@ sub link_github_go_if_available
224224

225225
say "Find already installed go version $target";
226226
mkdir_p("$dest_dir/go");
227-
foreach my $subdir (qw(bin src pkg))
227+
foreach my $file (qw(bin src pkg),
228+
(at_least($target, v1.21) ? 'go.env' : ()))
228229
{
229-
symlink("$goroot/$subdir", "$dest_dir/go/$subdir")
230-
or die "symlink($goroot/$subdir, $dest_dir/go/$subdir): $!\n";
230+
symlink("$goroot/$file", "$dest_dir/go/$file")
231+
or die "symlink($goroot/$file, $dest_dir/go/$file): $!\n";
231232
}
232233
say "go version $target symlinked and available as $dest_dir/go/bin/go";
233234
return 1;
@@ -273,12 +274,14 @@ sub install_go
273274
if ($EXT eq 'zip')
274275
{
275276
exe(qw(curl -L -s -o x.zip), $url);
276-
exe(qw(unzip -q x.zip go/bin/* go/pkg/**/* go/src/**/*));
277+
exe(qw(unzip -q x.zip go/bin/* go/pkg/**/* go/src/**/*),
278+
(at_least($version, v1.21) ? 'go/go.env' : ()));
277279
unlink 'x.zip';
278280
}
279281
else
280282
{
281-
exe("curl -L -s \Q$url\E | tar zxf - go/bin go/pkg go/src");
283+
exe("curl -L -s \Q$url\E | tar zxf - go/bin go/pkg go/src"
284+
. (at_least($version, v1.21) ? ' go/go.env' : ''));
282285
}
283286

284287
my $goroot_env;
@@ -373,7 +376,8 @@ sub install_prebuilt_tip
373376

374377
mkdir_p("$dest_dir/go");
375378

376-
$status = exe_status(qw(tar zxf gotip.tar.gz -C), "$dest_dir/go", qw(bin pkg src));
379+
$status = exe_status(qw(tar zxf gotip.tar.gz -C), "$dest_dir/go",
380+
qw(bin pkg src go.env));
377381
unlink 'gotip.tar.gz';
378382
if ($status != 0)
379383
{
@@ -605,3 +609,15 @@ sub go_env
605609

606610
return $res;
607611
}
612+
613+
sub at_least
614+
{
615+
my($version, $cmp) = @_;
616+
617+
unless (ref $version)
618+
{
619+
$version = eval { version->parse("v$version") } // return;
620+
}
621+
622+
return $version ge $cmp
623+
}

0 commit comments

Comments
 (0)