Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
25 changes: 25 additions & 0 deletions features/goserver/README.md
Original file line number Diff line number Diff line change
@@ -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
10 changes: 10 additions & 0 deletions features/goserver/build.bat
Original file line number Diff line number Diff line change
@@ -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
10 changes: 10 additions & 0 deletions features/goserver/build.sh
Original file line number Diff line number Diff line change
@@ -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
5 changes: 5 additions & 0 deletions features/goserver/conanfile.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[requires]
go-martini/1.0@

[imports]
src, * -> ./deps/src
19 changes: 19 additions & 0 deletions features/goserver/recipes/conanfile_go-inject.py
Original file line number Diff line number Diff line change
@@ -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)
19 changes: 19 additions & 0 deletions features/goserver/recipes/conanfile_go-martini.py
Original file line number Diff line number Diff line change
@@ -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)
11 changes: 11 additions & 0 deletions features/goserver/src/server/main.go
Original file line number Diff line number Diff line change
@@ -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()
}