Skip to content

Commit

Permalink
go: use go install for binary package installation on Go 1.16+
Browse files Browse the repository at this point in the history
  • Loading branch information
maxfierke committed Jan 28, 2024
1 parent 258e952 commit 5ec7aa6
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/mstrap/runtimes/go.cr
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down

0 comments on commit 5ec7aa6

Please sign in to comment.