Giter Club home page Giter Club logo

vg's People

Contributors

13k avatar cclauss avatar flibustenet avatar glasser avatar jeltef avatar jostyee avatar lachie avatar nekuromento avatar pascaldekloe avatar perfectnewer avatar tbarbugli avatar trenton42 avatar weaming 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  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

vg's Issues

With --full-isolation, package fails to import its own internal packages

Here's a simplified example:
(hello) callpraths@remote-workstation:/mnt/work/go/src/hello$ tree

.
├── hello
├── hello.go
└── internal
    └── hello2
        └── hello2.go

(hello) callpraths@remote-workstation:/mnt/work/go/src/hello$ cat internal/hello2/hello2.go
package hello2

    import (
            "fmt"
    )

    func Do() {
            fmt.Println("hello2")
    }

(hello) callpraths@remote-workstation:/mnt/work/go/src/hello$ vim hello.go
(hello) callpraths@remote-workstation:/mnt/work/go/src/hello$ cat hello.go

    package main
    import (
            "hello/internal/hello2"
    )

    func main() {
        hello2.Do()
    }

Without vg:
callpraths@remote-workstation:/mnt/work/go/src/hello$ go run hello.go
hello2

With vg (but fallback to GOPATH):
callpraths@remote-workstation:/mnt/work/go/src/hello$ vg init
Creating workspace "hello" with global fallback import mode
Activating hello
Linking /mnt/work/go/src/hello to workspace 'hello'
(hello) callpraths@remote-workstation:/mnt/work/go/src/hello$ go run hello.go
hello2

With vg (full isolation):
(hello) callpraths@remote-workstation:/mnt/work/go/src/hello$ vg destroy
Destroying workspace "hello"
Deactivating hello
callpraths@remote-workstation:/mnt/work/go/src/hello$ vg init --full-isolation
Creating workspace "hello" with full isolation import mode
Installing local sources at "/mnt/work/go/src/hello" in workspace as "hello" using bindfs
Persisting the local install for "hello"
Activating hello
Uninstalling "hello" from workspace
Unmounting bindfs mount at "/home/callpraths/.virtualgo/hello/src/hello"
Removing sources at "/home/callpraths/.virtualgo/hello/src/hello"
Installing local sources at "/mnt/work/go/src/hello" in workspace as "hello" using bindfs
Persisting the local install for "hello"
Linking /mnt/work/go/src/hello to workspace 'hello'
(hello) callpraths@remote-workstation:/mnt/work/go/src/hello$ go run hello.go
hello.go:4:2: use of internal package not allowed

vg auto-activate works incorrectly

Case 1: Destroyed environments are re-created again with cd

[host]xyz_proj$ vg init
...
(xyz_proj) [host]xyz_proj$ vg destroy
[host]xyz_proj$ cd any_other_folder
[host]any_other_folder$ cd xyz_proj
Creating workspace "xyz_proj" with global fallback import mode
Activating "xyz_proj"
(xyz_proj) [host]xyz_proj$

I've managed to fix the problem with new condition to activate function:

__vg_auto_activate() {
    activation_root=$PWD
    while [ "$activation_root" != "" ]; do
        if [ -f "$activation_root/.virtualgo" ]; then
            new_virtualgo_name=$(cat "$activation_root/.virtualgo")
            if [ "" = "$VIRTUALGO" ] || [ "$new_virtualgo_name" != "$VIRTUALGO" ]; then
                # that's what I added
                if [[ -d "$HOME/.virtualgo/$new_virtualgo_name" ]];then   # <=========
                vg activate "$new_virtualgo_name"
                fi
            fi
            return

Also, I think that vg destroy should do vg unlink automatically

Case 2: Activate in child folder of folder that is linked to some vg environment will create new environment instead of activating parent.

src is a child folder of goenv:

(goenv) [host]src$ vg deactivate
Deactivating goenv
[host]src$ vg activate
Creating workspace "src" with global fallback import mode
Activating src

Override virtualgoroot (~/.virtualgo)?

We have a project that uses a variety of home-grown shell scripts to provide a similar experience to vg. I'd like to replace it with vg.

One nice feature of our project is that you can check it out anywhere and it will work immediately (as long as you run our shell wrapper, which works well with direnv). We store the equivalent to the ~/.virtualgo/V directory inside a gitignored directory in the repo itself. That way you can have multiple checkouts and they just work.

So to port to vg our scripts (we'd still have direnv scripts because we set up non-Go environments as well) would like to be able to just use a fixed environment name and a virtualgoroot that's not global, rather than a global virtualgoroot and a variable environment name.

It looks like we should be able to just define, say, $VIRTUALGOROOT, and use it instead of ~/.virtualgo in the shell scripts and utils.Virtualgoroot. Is that a PR you'd take?

Virtualgo does not work well with delve

I'm currently using Gogland for go development. Switching over to vg definitely helps with reducing CPU load and in general making gogland snappier.

Running tests still works as expected. When setting breakpoints and running tests in debug mode, it seems like the breakpoints are not registering at all. My current fallback solution is to set GOPATH back to my default global path, effectively disabling vg, but that defeats the purpose of using it in the first place :)

This may be an OS X thing and how it deals with symlinks, but I thought I'd see if anyone else has a good way of dealing with this.

go-plus plugin cannot find virtualgo installed packages

I'm using Atom and go-plus plugin. After I installed grpc package, the go-plus showed the following error:

main.go:8:2: cannot find package "google.golang.org/grpc" in any of:
/usr/local/opt/go/libexec/src/google.golang.org/grpc (from $GOROOT)
/[mypath]/src/google.golang.org/grpc (from $GOPATH)

but I can run it in the terminal without any error:

go run main.go

go list incorrect

using 0.6.5 the output of go list ./... is incorrect
eg.

github.com/goadapp/goad is listed as _/Users/tommaso/src/go_development/src/github.com/goadapp/goad

'vg ensure' fails when project directory and home directory are located on different devices

Command vg ensure run within the project directory and activated workspace returns:

(project) [user@machine project][✔]$ vg ensure
Running "dep ensure"
Error: Couldn't move the vendor directory to the active workspace: rename vendor /home/user/.virtualgo/project/src: invalid cross-device link
Usage:
  vg ensure [-- [arguments to dep ensure]] [flags]

Flags:
  -h, --help   help for ensure

Couldn't move the vendor directory to the active workspace: rename vendor /home/uservirtualgo/project/src: invalid cross-device link

This is caused by the fact that my home directory is located on one device (/dev/sdb3) and my project directory on another (/dev/sda1). Call to os.Rename (https://github.com/GetStream/vg/blob/master/cmd/ensure.go#L143) will return a LinkError.

vg environment name does not display in the zsh

Hi,

I'm using POWERLEVEL9K theme on zsh. When I activate a virtual environment, the theme doesn't change to show the name of the current environment. I sometimes forgot to deactivate it. How to set up zsh for showing the name of activated environment?

thanks

P.S: I'm using OSX and my zsh is the latest version.

How do I pin the version of executables?

There seems to be no writeup on this matter in the documentations (aka README). I'm using vg with dep and my current way of installing executables is putting them in required field inside Gopkg.toml

Changing workspace breaks fish shell

When changing from one workspace to another in fish, the prompt updating fails. It's worth noting that I've have a function in my fish config also called fish_prompt:

https://github.com/karlek/dotfiles/blob/master/.config/fish/conf.d/08-prompt.fish

(gateway) (^._.^)ノ elysium @ /home/_/.local/share/go/src/github.com/karlek/tf/gateway $ ../keysmith/
Deactivating gateway
functions: Function “fish_prompt” already exists. Cannot create copy “_old_fish_prompt”
- (line 109): 
        functions -c _old_fish_prompt fish_prompt
        ^
in function “_vg_deactivate”
	called on line 46 of file -

in function “_vg_activate”
	called on line 13 of file -
	with parameter list “activate keysmith”

in function “vg”
	called on line 189 of file -
	with parameter list “activate keysmith”

in function “__vg_auto_activate”
	called on line 5 of file /usr/share/fish/functions/cd.fish
	with parameter list “VARIABLE SET PWD”

in event handler: handler for variable “PWD”


       functionsfunctions - print or erase functions
        -

   Synopsis
       functions [ -a | --all ] [ -n | --names ]
       functions [ -D | --details ] [ -v ] FUNCTION
       functions -c OLDNAME NEWNAME
       functions -d DESCRIPTION FUNCTION
       functions [ -e | -q ] FUNCTIONS...

functions: Type “help functions” for related documentation

Activating keysmith
(keysmith) _@elysium ~/.l/s/g/s/g/k/t/keysmith>

Editing other packages

The VG version of pip install -e . isn't clearly explained. Say that I'm working on a package and want to clone and edit one of the dependencies, how do i do that with VG?

Tommaso showed me one solution, we should document it.

"vg ensure -- -update" does not play well with persisted local packages

Below github.com/qubit-sh/go-crypto is a persisted package (symlinked from /Users/mmuthanna/.virtualgo/qubit/src/github.com/qubit-sh/go-crypto.)

$ vg ensure -- -v -update
Running "dep ensure -v -update"
Root project is "github.com/qubit-sh/xpoller"
 1 transitively valid internal packages
 2 external packages imported from 2 projects
(0)   ✓ select (root)
(1)     ? attempt github.com/qubit-sh/go-crypto with 1 pkgs; 1 versions to try
(1)         try github.com/qubit-sh/go-crypto@master

<SNIP>

Uninstalling "github.com/qubit-sh/go-crypto" from workspace
  Removing sources at "/Users/mmuthanna/.virtualgo/qubit/src/github.com/qubit-sh/go-crypto"
Error: Couldn't move the vendor directory to the active workspace: rename vendor /Users/mmuthanna/.virtualgo/qubit/src: no such file or directory
Usage:
  vg ensure [-- [arguments to dep ensure]] [flags]

Flags:
  -h, --help   help for ensure

Couldn't move the vendor directory to the active workspace: rename vendor /Users/mmuthanna/.virtualgo/qubit/src: no such file or directory

The workaround is to call vg ensure immediately after to relink the persistent package.

Breaks when initial GOPATH is empty

When I activate a workspace using vg while my GOPATH is empty, the new GOPATH ends in a colon, followed by the original empty GOPATH, which confuses go:

matthijs@grubby:/$ cd /path/to/bar/
Activating bar
Uninstalling "github.com/foo/bar" from workspace
  Unmounting bindfs mount at "/home/matthijs/.virtualgo/bar/src/github.com/foo/bar"
  Removing sources at "/home/matthijs/.virtualgo/bar/src/github.com/foo/bar"
  Removing "github.com/foo/bar" from locally installed packages
Installing local sources at "." in workspace as "github.com/foo/bar" using bindfs
(bar) matthijs@grubby:/path/to/bar$ echo $GOPATH
/home/matthijs/.virtualgo/bar:
(bar) matthijs@grubby:/path/to/bar$ go build
go: GOPATH entry is relative; must be absolute path: "".
For more details see: 'go help gopath'

I realize that using a fully-isolated workspace would work here, but would it perhaps make sense to just ignore the previous GOPATH if it is empty?

vg init

combines activate and connect

vg help prints Cobra's placeholder intro text

The first lines of vg help look suspiciously like a placeholder text :)

$ vg help
A longer description that spans multiple lines and likely contains
examples and usage of using your application. For example:

Cobra is a CLI library for Go that empowers applications.
This application is a tool to generate the needed files
to quickly create a Cobra application.

(...)

(vg 0.6.0)

vg setup improments

  • Figure out if .bashrc/.bash_profile/.profile should be changed
  • Don't duplicate eval lines when running setup twice
  • Don't edit files for shells that are not installed

dep init does not work

dep init does not work when vg is activated (path is not in GOPATH)

workaround:

vg globalExec -- dep init

Relative paths passed to localInstall work unexpectedly

I'm a bit stubborn when it comes to go and directory organisation, so I tried to use vg to create a git clone of my project in whatever directory I wanted (without having to have it in src/github.com/foo/bar). I was hoping that that would take care of creating a virtual GOPATH somewhere, and automatically link my project directory into there in an appropriate place. Unfortunately that did not happen, so I needed a manual vg localInstall to get my project directory linked (which makes sense, since vg does not know the full package name of my project).

So, I tried:

/path/to/bar$ vg localInstall github.com/foo/bar .
/path/to/bar$ mount|grep bar
/path/to/bar on /home/matthijs/.virtualgo/bar/src/github.com/foo/bar type fuse (rw,nosuid,nodev,relatime,user_id=1000,group_id=1000,default_permissions)

Which indeed correctly puts /path/to/bar in the virtual $GOPATH/src/github.com/foo/bar. However, in virtualgo.toml it stores the original relative path ., and it seems this path is interpreted relative to the current directory, not the project root. E.g. if I deactivate the workspace and then jump into a subdirectory of my project, things get broken:

/$ cd /path/to/bar/sub/
Activating bar
Uninstalling "github.com/foo/bar" from workspace
Unmounting bindfs mount at "/home/matthijs/.virtualgo/bar/src/github.com/foo/bar"
Removing sources at "/home/matthijs/.virtualgo/bar/src/github.com/foo/bar"
Removing "github.com/foo/bar" from locally installed packages
Installing local sources at "." in workspace as "github.com/foo/bar" using bindfs
(bar) matthijs@grubby:/path/to/bar/sub$ mount|grep bar
/path/to/bar/sub on /home/matthijs/.virtualgo/bar/src/github.com/foo/bar type fuse (rw,nosuid,nodev,relatime,user_id=1000,group_id=1000,default_permissions)

Should the path passed to localInstall be made absolute before storing it?

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.