Skip to content

Commit

Permalink
Add go.mod heuristics
Browse files Browse the repository at this point in the history
  • Loading branch information
goto1134 committed Aug 16, 2024
1 parent d190ad8 commit 1ec5ead
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/linguist/heuristics.yml
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,8 @@ disambiguations:
pattern: '<!ENTITY '
- language: NMODL
pattern: '\b(NEURON|INITIAL|UNITS)\b'
- language: Go Module
pattern: '^\s*module\s+(\(|[\w\-./]+|"[^"]*")\s*$'
- language: Modula-2
pattern: '^\s*(?i:MODULE|END) [\w\.]+;'
- language: [Linux Kernel Module, AMPL]
Expand Down
12 changes: 12 additions & 0 deletions test/fixtures/Go Module/multiline/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module (
golang.org/x/oauth2
)

go 1.11

require (
cloud.google.com/go v0.34.0
golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4 // indirect
google.golang.org/appengine v1.4.0
)
10 changes: 10 additions & 0 deletions test/fixtures/Go Module/quoted/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module "golang.org/x/oauth2"

go 1.11

require (
cloud.google.com/go v0.34.0
golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4 // indirect
google.golang.org/appengine v1.4.0
)
10 changes: 10 additions & 0 deletions test/fixtures/Go Module/unquoted/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module golang.org/x/oauth2

go 1.11

require (
cloud.google.com/go v0.34.0
golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4 // indirect
google.golang.org/appengine v1.4.0
)
3 changes: 3 additions & 0 deletions test/test_heuristics.rb
Original file line number Diff line number Diff line change
Expand Up @@ -691,6 +691,9 @@ def test_mod_by_heuristics
"Modula-2" => all_fixtures("Modula-2", "*.mod"),
"NMODL" => all_fixtures("NMODL", "*.mod"),
"XML" => all_fixtures("XML", "*.mod"),
"Go Module" => Dir.glob("#{fixtures_path}/Go Module/multiline/go.mod") +
Dir.glob("#{fixtures_path}/Go Module/quoted/go.mod") +
Dir.glob("#{fixtures_path}/Go Module/unquoted/go.mod"),
["Linux Kernel Module", "AMPL"] => all_fixtures("Linux Kernel Module", "*.mod"),
["Linux Kernel Module", "AMPL"] => all_fixtures("AMPL", "*.mod"),
})
Expand Down

0 comments on commit 1ec5ead

Please sign in to comment.