Git Product home page Git Product logo

gom's Introduction

gom - Go Manager

Build Status

Why

The go get command is useful. But we want to fix the problem where package versions are different from the latest update. Are you going to do go get -tags=1.1 ..., go get -tag=0.3 for each of them? We want to freeze package version. Ruby's bundle is awesome.

Installation

go get github.com/mattn/gom

Gomfile

gom 'github.com/mattn/go-runewidth', :tag => 'go1'
gom 'github.com/mattn/go-scan', :commit => 'ecb144fb1f2848a24ebfdadf8e64380406d87206'
gom 'github.com/daviddengcn/go-colortext'
gom 'github.com/mattn/go-ole', :goos => 'windows'

# Execute only in the "test" environment.
group :test do
    gom 'github.com/mattn/go-sqlite3'
end

# Execute only for the "custom_group" group.
group :custom_group do
    gom 'github.com/golang/lint/golint'
end

By default gom install install all packages, except those in the listed groups. You can install packages from groups based on the environment using flags (development, test & production) : gom -test install

Custom groups my be specified using the -groups flag : gom -test -groups=custom_group,special install

Usage

Create _vendor directory and bundle packages into it

gom install

Build on current directory with _vendor packages

gom build

Run tests on current directory with _vendor packages

gom test

Generate .travis.yml that uses gom test

gom gen travis-yml

You can always change the name relative to the current $GOPATH directory using an environment variable: GOM_VENDOR_NAME

$ # to use a regular $GOPATH/src folder you should specify GOM_VENDOR_NAME equal '.'
$ GOM_VENDOR_NAME=. gom <command>

Tutorial

Writing Gomfile and bundle

$ ls
main.go

$ gom gen gomfile

$ cat Gomfile
gom 'github.com/daviddengcn/go-colortext'
gom 'github.com/mattn/go-runewidth'

$ gom install
installing github.com/daviddengcn/go-colortext
installing github.com/mattn/go-runewidth

$ find \_vendor/src -maxdepth 2
\_vendor/src
\_vendor/src/github.com
\_vendor/src/github.com/daviddengcn
\_vendor/src/github.com/mattn

$ gom build

If you want to bundle specified tag, branch or commit

gom 'github.com/mattn/go-runewidth', :tag => 'tag_name'
gom 'github.com/mattn/go-runewidth', :branch => 'branch_name'
gom 'github.com/mattn/go-runewidth', :commit => 'commit_name'

If you want to bundle a repository that go get can't access

gom 'github.com/username/repository', :command => 'git clone http://example.com/repository.git'

If you want to change local repository directory with command 'git clone', also skipdep and insecure, which is useful in internal network environment.

gom 'github.com/username/repository', :private => 'true', :target => 'repository', :insecure=>'true', :skipdep=>'true' 

Todo

  • Documentation

Author

Yasuhiro Matsumoto [email protected]

License

MIT: http://mattn.mit-license.org/2013

gom's People

Contributors

brunoksato avatar cubicdaiya avatar darthsim avatar hnakamur avatar jabley avatar jawsthegame avatar kawaken avatar kevinhankens avatar koron avatar laysakura avatar lyuyun avatar mattn avatar michaelmior avatar nono avatar okzk avatar orofarne avatar owlycode avatar robert-zaremba avatar ruitao avatar sergeylanzman avatar shawnps avatar smira avatar sudharsh avatar syohex avatar tinygrasshopper avatar uhamc avatar yudppp avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gom's Issues

generate gomfile with commit

Can gom generate gomfile with commit info to freeze package version?

like

gom 'github.com/mattn/go-scan', :commit => 'ecb144fb1f2848a24ebfdadf8e64380406d87206'
...

Go 1.6, gom and vendor packages

Hi @mattn

I noticed that using go1.6, gom install places all vendor packages in a vendor folder (rather than _vendor), which I understand it's now the Go1.6 default location.

Within the vendor folder, gom places my all the vendor modules outside the src directory, which is not created anymore. When I try to build my go project, an error is thrown since go expects my vendor modules to live in vendor/src/github.com/etc rather than vendor/github.com/etc

Is this an issue with gom, go1.6 or my current set up?

Thanks!

More general import paths

Hi,

I was reading through the source code, wondering how you handle private repositories and stuff. I am not sure it's a good idea to implement private repositories by just prepending git@ or so. That will not work if the hosting service is not GitHub or BitBucket, there can be some other username people might want to use. Or they might feel like cloning over https.

To put it simply, it could make sense to do something similar to what package.json for NPM does:

git://github.com/user/project.git#commit-ish
git+ssh://user@hostname:project.git#commit-ish
git+ssh://user@hostname/project.git#commit-ish
git+http://user@hostname/project/blah.git#commit-ish
git+https://user@hostname/project/blah.git#commit-ish

And something similar for other versioning systems.

What do you think?

Regards,
Ondrej Kupka

Error with package in subdirectory and commit

Hi,

I have this Gomfile:

gom 'github.com/garyburd/redigo/redis', :commit => '4053c2dadc31b162d7e70a88e659785bfcbbfe62'

If I run gom install, it fails wih this message:

$ gom install  
installing github.com/garyburd/redigo/redis
can't load package: package github.com/garyburd/redigo: no Go source files in /home/nono/dev/workers/pdf/vendor/src/github.com/garyburd/redigo

Use with Revel

How can I use Gom with Revel?

I tried gom exec revel run myapp, but I get the following error:

ERROR 2014/01/02 16:07:21 revel.go:239: Failed to import myapp with error: cannot find package "myapp" in any of:
    /home/lee/.gvm/gos/go1.2/src/pkg/myapp (from $GOROOT)
    /home/lee/Code/gomuck/src/myapp/vendor/src/myapp (from $GOPATH)
gom:  exit status 1

'gom install' failed on Go 1.6 with GO15VENDOREXPERIMENT=0

% go version
go version go1.6.3 linux/amd64
% echo $GO15VENDOREXPERIMENT
0
% gom install
downloading github.com/mattn/gover
downloading github.com/hashicorp/go-version
downloading github.com/daviddengcn/go-colortext
gom:  open /home/syohei/go/src/github.com/mattn/gom/_vendor/src: no such file or directory
% echo $?
1

Support for local and external packages?

Hi,

I'm trying gom for the first time, so it's possible I'm doing something wrong. I have the following structure for a project in a private repo (not go getable, requires auth):

private/cmd
private/cmd/package1
private/cmd/package2

cmd is a main package, and it uses cmd/package1 and cmd/package2. They are part of the same repo, so I don't want to vendor the packages. But cmd and the packages use external dependencies from github and google code.

I generated the Gomfile, and deleted the lines for the cmd/package1 and cmd/package2. When I run gom build, it complains that he cannot find those packages. Is this a supported scenario, to have some dependencies resolved in the standard GOPATH, and some resolved using the vendor/gom-defined GOPATH?

Thanks,
Martin

Install part of repository with custom :command

I use gom mostly for use our mirrored repository. for example (since Iran's firewall blocked bitbucket.org for any reason that I don't know and can't understand) we mirror the goose repository in a locally installed gitlab repository (go get can not understand gitlab :/ ).
now this line :

gom 'bitbucket.org/liamstask/goose/cmd/goose', :command => 'git clone http://example.com/mirrors/goose.git'

is not working. its clone the repo inside the src/bitbucket.org/liamstask/goose/cmd/goose which is not correct.
Also this :

gom 'bitbucket.org/liamstask/goose', :command => 'git clone http://example.com/mirrors/goose.git'

Is failed. since there is no go file in root of this repository. (this repository is just an example, and we have this problem with some other repository too)

Is there anything I can do to fix this? any hack or even a feature that I can implement, please let me know.

Thanks.

Go 1.6 and vendor folder renaming

Something changed between go versions and that is causing package dependencies to be installed in vendor folder rather than usual _vendor folder.

This only happens when gom is run from custom location. For example:

export GOPATH=$(pwd -L)
export PATH=$GOPATH/bin:$PATH
go get github.com/mattn/gom
gom install #will install dependencies in vendor folder while using golang 1.6

I usually use above pattern for self-contained project specific Makefile. This problem does not happen when I run gom install from globally configured GOPATH.

[RFC] pr attribute

Specify pull-request ids

gom 'github.com/mattn/go-colorable', :pr => 53
gom 'github.com/mattn/go-colorable', :pr => [53,124]

gom install failed for mgo

For the recent commits around Dec1 or Dec 2, 2015, I got the following error on gom install:

# gopkg.in/mgo.v2/internal/sasl
internal/sasl/sasl.go:15:24: fatal error: sasl/sasl.h: No such file or directory
 // #include <sasl/sasl.h>
                        ^

when running a Dockerfile from golang:1.5.1 (from buildpack-deps:jessie-scm).

I could have installed it on the revsion 78a9091

Thanks.

gom install --save

In node.js package manager npm, I can do

npm install --save koa
npm install --save-dev should.js

It will add dependencies to package.json automatically. It will be very cool if gom can install and then add dependencies to Gomfile.

gom install --save github.com/mattn/gom
gom install --save-dev  github.com/xxxx/testing/assert

Can not work in Go1.7 and more?

Hello.
@mattun
@h3poteto

Vendoring could not work in my project.
I got this package(gom) and built my project today.

I think that this fix may be inappropriate.
#81

When did vendoring behavior change? I could not find this release note.
If you can, I would like to teach me.
https://blog.golang.org/go1.7

Sincerely,

-- detail
Using version is 1.7.3

GOPATH setting

GOPATH=/path/to/project:/path/to/project/lib

Error sample

app/app.go:26:2: cannot find package "github.com/labstack/echo" in any of:
    /path/to/project/src/vendor/github.com/labstack/echo (vendor tree)
    /usr/local/go/src/github.com/labstack/echo (from $GOROOT)
    /path/to/project/src/github.com/labstack/echo (from $GOPATH)
    /path/to/project/lib/src/github.com/labstack/echo

--

英語だと説明不足感があるので日本語で補足します。
下記バージョンだと、Go1.7.3の環境においてvendor/でビルドできました。
393e714

プルリクエスト(#81)のエラーを見ていると、vendor treeに関するエラー表示がないため、
build/install時にvendorへの参照がおこなわれていないのではないかと思います。
(おそらくGOPATHにvendorが含まれている)

確認いただけると、助かります。
よろしくお願いします。

Could not install ffjson

After this commit f4cb457 I could not install gom 'github.com/pquerna/ffjson'

github.com/pquerna/ffjson/tests/go.stripe
go build github.com/pquerna/ffjson/tests/go.stripe: no buildable Go source files in /gopath/src/github.com/pubnative/ad_server/_vendor/src/github.com/pquerna/ffjson/tests/go.stripe
gom:  exit status 1

Consider adding GO15VENDOREXPERIMENT support

In 1.5 the go command will read the environment variable GO15VENDOREXPERIMENT. If enabled, it will use the local "/vendor/" folder for dependencies.

Will you consider supporting this approach?

gom: cannot find package "C"

From master, when I run gom gen file it fails with this error message:

gom:  cannot find package "C" in any of:
        /usr/local/go/src/C (from $GOROOT)
        /home/vagrant/workspace/go/src/C (from $GOPATH)

My current project imports another project that uses cgo.

gom lock

I think, there is bug in gom/gen.go

        if isDir(filepath.Join(p, ".git")) {
            vcs = git
        } 

Gomfile:

gom 'github.com/aws/aws-sdk-go/aws'
gom 'github.com/aws/aws-sdk-go/aws/awserr'
gom 'github.com/aws/aws-sdk-go/aws/awsutil'
gom 'github.com/aws/aws-sdk-go/aws/client'
gom 'github.com/aws/aws-sdk-go/aws/client/metadata'
gom 'github.com/aws/aws-sdk-go/aws/corehandlers'
gom 'github.com/aws/aws-sdk-go/aws/credentials'
gom 'github.com/aws/aws-sdk-go/aws/credentials/ec2rolecreds'
gom 'github.com/aws/aws-sdk-go/aws/defaults'
gom 'github.com/aws/aws-sdk-go/aws/ec2metadata'
gom 'github.com/aws/aws-sdk-go/aws/request'
gom 'github.com/aws/aws-sdk-go/aws/session'
gom 'github.com/aws/aws-sdk-go/private/endpoints'
gom 'github.com/aws/aws-sdk-go/private/protocol/query'
gom 'github.com/aws/aws-sdk-go/private/protocol/query/queryutil'
gom 'github.com/aws/aws-sdk-go/private/protocol/rest'
gom 'github.com/aws/aws-sdk-go/private/protocol/xml/xmlutil'
gom 'github.com/aws/aws-sdk-go/private/signer/v4'
gom 'github.com/aws/aws-sdk-go/service/sns'

but .git dir is only on level https://github.com/aws/aws-sdk-go/.

gom run

I want to execute gom run {src.go}

failed dependent package installation

gom install した時に依存関係のあるパッケージがインストールされずにエラーになる場合があります。
Gomfileの記載は以下のとおりです。

gom 'github.com/aws/aws-sdk-go/service/sqs', :commit => 'a28ecdc9741b7905b5198059c94aed20868ffc08'

Error message

../../aws/credentials/shared_credentials_provider.go:8:2: cannot find package "github.com/vaughan0/go-ini" in any of:

12/1のコミット(3bd6544) 以降に発生しているように思われます。

Weird error when a package is already in $GOPATH

Hi,

I'm trying gom, but I found a weird error. If I have already installed a package with go install (for example github.com/jrallison/go-workers), and then I create a Gomfile with:

gom 'github.com/jrallison/go-workers', :commit => 'f9540adf4c3635a54663b9c55671b54de77d19fc'

If I run gom install, it fails with a weird error:

$ gom install
installing github.com/jrallison/go-workers
gom:  gom currently support git/hg for specifying tag/branch/commit

And vendor/ remains empty.

Gom run

It would be nice to be able to run: gom run which would be the same as doing: gom run main.go anotherfile.go andanother.go etc.go

I know most people probably do gom run *.go however this doesn't work if you have some_test.go file in that path. The idea then, is to make "go run" work just like "go build" which is to compile the list of .go app files.

Even though go v1.2 doesn't support this, it's being discussed as a potential thing to support: https://code.google.com/p/go/issues/detail?id=5164 / https://codereview.appspot.com/50970043/

gom build/run can't find libs when they installed with $GO15VENDOREXPERIMENT=1

@hnakamur @mattn
First of all, thank you for open-sourcing such a cool library! I was really happy when I found gom supports GO15VENDOREXPERIMENT, but here is my problem. The below is repro process.

https://github.com/achiku/sample-golang-packaging-gom

$ go version
go version go1.5.1 darwin/amd64
$ echo $GO15VENDOREXPERIMENT
1
$ go get github.com/mattn/gom
$ git clone [email protected]:achiku/sample-golang-packaging-gom.git 
$ cd sample-golang-packaging-gom
$ gom install
$ find vendor -type d -maxdepth 2
vendor
vendor/github.com
vendor/github.com/fatih
vendor/github.com/mattn
vendor/github.com/shiena
vendor/pkg
vendor/pkg/darwin_amd64
$ gom run main.go  # it fails
$ gom build  # it fails
$ mkdir vendor/src
$ mv vendor/github.com vendor/src
$ gom run main.go
Hello, world!
$ gom build  # it succeeds

Is there any reason to move vendor/src to vendor after building libraries installed by gom install? (GO15VENDORINGEXPERIMENT is introduced in this pr #57) It seems like plain go build can also search for vendor/src if GO15VENDORINGEXPERIMENT is on, so leaving libraries in vendor/src seems ok to me. I'm pretty new to golang, so might be missing something important.

Proposal: rename vendor to _vendor

go tools ignore filenames that start with _ (and .). With current name of vendor subdirectory command go test ./... if run in repository root would go inside vendor subdirectory, find packages there and launch tests, which is usually not desired. The same applies to gom test ./... of course, and things like go tool vet.

If vendor is renamed to _vendor, this should make �./... work as expected again.

I can submit pull request if it sounds ok. Probably this could be configured in Gomfile?

Command and Library

How does it handle a project that is a library, so e.g. some files have package foo and also has a command foo, so e.g. one file has package main.

Why the ruby syntax?

I know this is a design decision, but I feel that it should be more like go. It seems less intuitive to have something written in go, for go, that looks like ruby simply because it was inspired by a ruby tool.

Can not detect go version

root@ubuntu-14:/opt/morningstar/src/github.com/mattn/gom# go version
go version xgcc (Ubuntu 4.9.3-0ubuntu4) 4.9.3 linux/amd64

root@ubuntu-14:/opt/morningstar/src/github.com/mattn/gom# gom
panic: Can not detect go version

goroutine 1 [running]:
github_com_mattn_gover.Version
/opt/morningstar/src/github.com/mattn/gover/ver.go:21
main.checkVendoringSupport
/opt/morningstar/src/github.com/mattn/gom/main.go:63
main.$init0
/opt/morningstar/src/github.com/mattn/gom/main.go:46

goroutine 3 [syscall]:
goroutine in C code; stack unavailable

gom install with :command

gom file:

gom 'git.xxx.com/xx/pfsdk', :command => 'git clone [email protected]:xx/pfsdk'

First time i exec gom install ,it works fine, but i exec it again ,it report an error:
fatal: destination path '/path/to/_vendor/src/git.xxx.com/xx/pfsdk' already exists and is not an empty directory

Command to lock the Gomfile

It'd be great if there was a command to lock the Gomfile with gom lock so that it stores all the git commit ids in a lockfile or in the Gomfile.

VIM, Syntastic and GOM

Hi,

I've contributed to the Syntastic project for VIM. This enables to have GOM as a checker instead of GO.

I decided to share this because I'm not the only one in that case. Please take a look and comment to share ideas.

vim-syntastic/syntastic#1269 (comment)

Best regards,
Yves

Failed `gom install `

Hi mattn,
The commit supported child package build.

Failed gom installafter this commit.

Failed Gomfile sample is

gom 'github.com/justinas/nosurf'

log:

$ gom install
downloading github.com/justinas/nosurf
warning: code.google.com is shutting down; import path code.google.com/p/go.net/websocket will stop working
warning: package github.com/justinas/nosurf/examples
    imports code.google.com/p/go.net/websocket
# github.com/justinas/nosurf/examples
examples/goji.go:15: templateString redeclared in this block
    previous declaration at examples/advanced.go:15
examples/goji.go:34: templ redeclared in this block
    previous declaration at examples/advanced.go:31
examples/goji.go:58: main redeclared in this block
    previous declaration at examples/advanced.go:55
examples/simple.go:12: templateString redeclared in this block
    previous declaration at examples/goji.go:15
examples/simple.go:31: templ redeclared in this block
    previous declaration at examples/goji.go:34
examples/simple.go:44: main redeclared in this block
    previous declaration at examples/goji.go:58
examples/web.go:12: templateString redeclared in this block
    previous declaration at examples/simple.go:12
examples/web.go:28: templ redeclared in this block
    previous declaration at examples/simple.go:31
examples/web.go:41: main redeclared in this block
    previous declaration at examples/simple.go:44
gom:  exit status 2

github.com/justinas/nosurf/examples can't use go get

My commit successed gom install

But this code is bad code. I want to set optional exclude path or not insalled child package.

What would be the best thing to do?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.