From 5ec7aa621065d1a14ddd1200aaf10883dca212ce Mon Sep 17 00:00:00 2001 From: Max Fierke Date: Sat, 27 Jan 2024 18:15:46 -0600 Subject: [PATCH] go: use go install for binary package installation on Go 1.16+ --- src/mstrap/runtimes/go.cr | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/mstrap/runtimes/go.cr b/src/mstrap/runtimes/go.cr index 719ce9f..f88c809 100644 --- a/src/mstrap/runtimes/go.cr +++ b/src/mstrap/runtimes/go.cr @@ -4,19 +4,26 @@ module MStrap # with Go via the chosen runtime manager and bootstrapping a Go project # based on conventions. class Go < Runtime + # :nodoc: + GO_INSTALL_MIN_VERSION = SemanticVersion.new(1, 16, 0) + def language_name : String "go" end def bootstrap if File.exists?("go.mod") - cmd "go mod download", quiet: true + runtime_exec "go mod download" end end def install_packages(packages : Array(Defs::PkgDef), runtime_version : String? = nil) : Bool packages.all? do |pkg| - cmd_args = ["get", "-u"] + cmd_args = if SemanticVersion.parse(runtime_version) >= GO_INSTALL_MIN_VERSION + ["install"] + else + ["get", "-u"] + end if version = pkg.version cmd_args << "#{pkg.name}@#{version}"