Class: AsdfDiscover::Searchers::GoMod

Inherits:
Object
  • Object
show all
Defined in:
lib/asdf_discover/searchers/go_mod.rb

Overview

Searches for a Go version in the go.mod file

Constant Summary collapse

GO_MOD =
"go.mod".freeze

Instance Method Summary collapse

Instance Method Details

#callObject



7
8
9
10
11
12
13
14
15
# File 'lib/asdf_discover/searchers/go_mod.rb', line 7

def call
  return NotFound unless File.exist?(GO_MOD)

  File.open(GO_MOD, "r").each_line do |line|
    return Found.new("golang", Regexp.last_match(1), GO_MOD) if line =~ /go ([0-9.]+)$/
  end

  NotFound
end