Skip to content

Commit

Permalink
Add golang source detector for new-app
Browse files Browse the repository at this point in the history
Adding golang source detector for oc new-app,
looks for main.go and Godeps

Fixes issue #12417
  • Loading branch information
coreydaley committed Jan 13, 2017
1 parent 398ca1a commit 77b08ef
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions examples/gitserver/hooks/detect-language
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,9 @@ if has project.json || hasglob '*.csproj'; then
exit 0
fi

if has main.go Godeps; then
echo "${prefix}golang"
exit 0
fi

exit 1
6 changes: 6 additions & 0 deletions pkg/generate/source/detector.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ var DefaultDetectors = Detectors{
DetectScala,
DetectDotNet,
DetectLiteralDotNet,
DetectGolang,
}

// DetectRuby detects Ruby source
Expand Down Expand Up @@ -74,6 +75,11 @@ func DetectLiteralDotNet(dir string) *Info {
return detect(".net", dir, "project.json", "*.csproj")
}

// DetectGolang detects Go source
func DetectGolang(dir string) *Info {
return detect("golang", dir, "main.go", "Godeps")
}

// detect returns an Info object with the given platform if the source at dir contains any of the argument files
func detect(platform string, dir string, globs ...string) *Info {
for _, g := range globs {
Expand Down

0 comments on commit 77b08ef

Please sign in to comment.