diff --git a/README.md b/README.md index e772e374..379e4364 100644 --- a/README.md +++ b/README.md @@ -69,6 +69,12 @@ Example on how to create multi-configuration debug/release packages covering the Documentation: https://docs.conan.io/en/latest/creating_packages/package_approaches.html#n-configs-1-package +### [Go Server](features/integrate_build_system) + +Shows how to integrate Go language and Conan package manager. + +Documentation: https://docs.conan.io/en/latest/howtos/other_languages_package_manager/go.html + ### Lockfiles diff --git a/features/goserver/README.md b/features/goserver/README.md new file mode 100644 index 00000000..99293f62 --- /dev/null +++ b/features/goserver/README.md @@ -0,0 +1,25 @@ +# Conan go server example + +## How to use + +Install **conan** from [Conan.io](https://conan.io) + + +Build all recipes: + + cd recipes/ + conan create conanfile_go-inject.py + conan create conanfile_go-inject.py + + +Install your requires in "deps" folder: + + conan install conanfile.txt + + +Include "deps" folder in GOPATH and run! + + + export GOPATH=${PWD}:${PWD}/deps + cd src/server + go run main.go diff --git a/features/goserver/build.bat b/features/goserver/build.bat new file mode 100755 index 00000000..2cf85543 --- /dev/null +++ b/features/goserver/build.bat @@ -0,0 +1,10 @@ +cd recipes +conan create conanfile_go-inject.py +conan create conanfile_go-martini.py +cd .. + +conan install conanfile.txt + +SET GOPATH=%GOPATH%;%CD%/deps +cd src/server +go build main.go diff --git a/features/goserver/build.sh b/features/goserver/build.sh new file mode 100755 index 00000000..56006bee --- /dev/null +++ b/features/goserver/build.sh @@ -0,0 +1,10 @@ +cd recipes +conan create conanfile_go-inject.py +conan create conanfile_go-martini.py +cd .. + +conan install conanfile.txt + +export GOPATH=${GOPATH}:${PWD}/deps +cd src/server +go build main.go diff --git a/features/goserver/conanfile.txt b/features/goserver/conanfile.txt new file mode 100644 index 00000000..1f6caa5a --- /dev/null +++ b/features/goserver/conanfile.txt @@ -0,0 +1,5 @@ +[requires] +go-martini/1.0@ + +[imports] +src, * -> ./deps/src diff --git a/features/goserver/recipes/conanfile_go-inject.py b/features/goserver/recipes/conanfile_go-inject.py new file mode 100644 index 00000000..c7034082 --- /dev/null +++ b/features/goserver/recipes/conanfile_go-inject.py @@ -0,0 +1,19 @@ +import os +from conans import ConanFile, tools + + +class GoInjectConan(ConanFile): + name = "go-inject" + version = "1.0" + license = "MIT" + homepage = "https://github.com/codegangsta/inject" + no_copy_source = True + + def source(self): + tools.get("https://github.com/codegangsta/inject/archive/v1.0-rc1.tar.gz", + sha256="22b265ea391a19de6961aaa8811ecfcc5bbe7979594e30663c610821cdad6c7b") + + def package(self): + self.copy(pattern='*', + dst=os.path.join("src", "github.com", "codegangsta", "inject"), + src="inject-1.0-rc1", keep_path=True) diff --git a/features/goserver/recipes/conanfile_go-martini.py b/features/goserver/recipes/conanfile_go-martini.py new file mode 100644 index 00000000..bc328c93 --- /dev/null +++ b/features/goserver/recipes/conanfile_go-martini.py @@ -0,0 +1,19 @@ +import os +from conans import ConanFile, tools + + +class GoMartiniConan(ConanFile): + name = "go-martini" + version = "1.0" + requires = "go-inject/1.0@" + license = "MIT" + homepage = "https://github.com/go-martini/martini" + no_copy_source = True + + def source(self): + tools.get("https://github.com/go-martini/martini/archive/v1.0.tar.gz", + sha256="3db135845d076d611f4420e0500e91625543a6b00dc9431cbe45d3571741281b") + + def package(self): + self.copy(pattern="*", dst=os.path.join("src", "github.com", "go-martini", "martini"), + src="martini-1.0", keep_path=True) diff --git a/features/goserver/src/server/main.go b/features/goserver/src/server/main.go new file mode 100644 index 00000000..90998451 --- /dev/null +++ b/features/goserver/src/server/main.go @@ -0,0 +1,11 @@ +package main + +import "github.com/go-martini/martini" + +func main() { + m := martini.Classic() + m.Get("/", func() string { + return "Hello world!" + }) + m.Run() +}