Virtualgo (or vg
for short) is a tool which provides workspace baseddevelopment for Go. Its main feature set that makes it better than othersolutions is as follows:
errcheck
) and codegen tools (e.g. protoc-gen-go
)Virtualgo doesn't do dependency resolution or version pinning itself, becausethis is a hard problem that's already being solved by other tools. Its approachis to build on top of these tools, such asdep
, to provide the features features listedabove.For people coming from Python vg
is very similar to virtualenv
, with dep
being respective to pip
. The main difference is that vg
is much easier touse than virtualenv
, because there's almost no mental overhead in using vg
.
The Go community is now using Go Modules to handle dependencies. This project is now mostly unmaintained. Please read more about this here.
Below is an example showing some basic usage of vg
. See further down and vg help
for more information and examples.
$ cd $GOPATH/src/github.com/GetStream/example
$ vg init # initial creation of workspace
# Now all commands will be executed from within the example workspace
(example) $ go get github.com/pkg/errors # package only present in workspace
(example) $ vg ensure # installs the dependencies of the example project using dep
(example) $ vg deactivate
$ cd ~
$ cd $GOPATH/src/github.com/GetStream/example
(example) $ # The workspace is now activated automatically after cd-ing to the project directory
The obvious question is: Why should you use vg
? What advantages does itbring over what you're using now? This obviously depends on what you're usingnow:
vendor
directorygo test ./...
running tests in the vendor
directorywhen using go
1.8 and below.GOPATH
inside yourworkspace, without running into confusing import errors.GOPATH
causing confusion about whatversion of a package you're using.GOPATH
sGOPATH
when you cd
into a directory.dep
and glide
allow forreproducible builds.GOPATH
.First install the package:
go get -u github.com/GetStream/vg
Although not required, it is recommended to installbindfs
as well. This gives the best experience whenusing full isolation and when usingvg localInstall
. If you do this, DON'T remove things manually from~/.virtualgo
. Only use vg destroy
/vg uninstall
, otherwise you can verywell lose data.
# OSX
brew install bindfs
# Ubuntu
apt install bindfs
# Arch Linux
pacaur -S bindfs # or yaourt or whatever tool you use for AUR
You can run the following command to configure all supported shellsautomatically:
vg setup
After this you have to reload (source
) your shell configuration file:
source ~/.bashrc # for bash
source ~/.zshrc # for zsh
source ~/.config/fish/config.fish # for fish
You can also edit your shell configuration file manually. Afterwards you stillhave to source
the file like explained above.
For bash put this in your ~/.bashrc
file:
command -v vg >/dev/null 2>&1 && eval "$(vg eval --shell bash)"
Or for zsh, put his in your ~/.zshrc
file:
command -v vg >/dev/null 2>&1 && eval "$(vg eval --shell zsh)"
Or for fish, put this in your ~/.config/fish/config.fish
file:
command -v vg >/dev/null 2>&1; and vg eval --shell fish | source
The following commands are the main commands to use vg
:
# The first command to use is the one to create and activate a workspace named
# after the current direcory
$ cd $GOPATH/src/github.com/GetStream/example
$ vg init
(example) $
# This command also links the current directory to the created workspace. This
# way the next time you cd to this directory the workspace will be activated
# automatically.
# (See below in the README on how to use the workspace from an IDE)
# All go commands in this shell are now executed from within your workspace. The
# following will install the most recent version of the cobra command and
# library inside the workspace
(example) $ go get -u github.com/spf13/cobra/cobra
(example) $ cobra
Cobra is a CLI library for Go that empowers applications.
......
# It's also possible to only activate a workspace and not link it to the
# current directory. If the workspace doesn't exist it will also be
# created on the fly. Activating a new workspace automatically deactivates
# a previous one:
(example) $ vg activate example2
(example2) $ cobra
bash: cobra: command not found
# To deactivate the workspace simply run:
(example2) $ vg deactivate
$ vg activate
(example) $
# When a workspace is active, a go compilation will try to import packages
# installed from the workspace first. In some cases you might want to use the
# version of a package that is installed in your global GOPATH though. For
# instance when you are fixing a bug in a dependency and want to test the fix.
# In these cases you can easily install a package from your global GOPATH
# into the workspace:
(example) $ vg localInstall github.com/GetStream/utils
# You can even install a package from a specific path:
(example) $ vg localInstall github.com/GetStream/utils ~/weird/path/utils
# You can also uninstall a package from your workspace again
(example) $ vg uninstall github.com/spf13/cobra
# NOTE: At the moment this only removes the sources and static libs in pkg/, not
# executables. So the cobra command is still available.
# See the following sections for integration with dependency management tools.
# And for a full overview of all commands just run:
(example) $ vg help
# For detailed help of a specific command run:
(example) $ vg help <command>
dep
integrationvg
integrates well with dep
(https://github.com/golang/dep):
# Install the dependencies from Gopkg.lock into your workspace instead of the
# vendor directory
vg ensure
# Pass options to `dep ensure`
vg ensure -- -v -update
It also extends dep
with a way to install executable dependencies. The vg
repo itself uses it to install the go-bindata
and cobra
command. It doesthis by adding the following in Gopkg.toml
:
required = [
'github.com/jteeuwen/go-bindata/go-bindata',
'github.com/spf13/cobra/cobra'
]
Running vg ensure
after adding this will install the go-bindata
and cobra
command in the GOBIN
of the current workspace.
As you just saw vg
reuses therequired
list from dep
.However, if you don't want to installall packages in the required
list you can achieve that by putting thefollowing in Gopkg.toml
:
[metadata]
install-required = false
You can also specify which packages to install without the required
list:
[metadata]
install = [
'github.com/jteeuwen/go-bindata/go-bindata',
'github.com/golang/mock/...', # supports pkg/... syntax
]
Even though dep
is the main tool that virtualgo integrates with. It's also possibleto use other dependency management tools instead, as long as they create avendor
directory. Installing executable dependencies is not supported though(PRs for this are welcome).
To use vg
with glide
works like this:
# Install dependencies into vendor with glide
glide install
# Move these dependencies into the workspace
vg moveVendor
A workspace can be set up in two different import modes, global fallback or fullisolation.The import mode of a workspace determines how imports from code behave and it ischosen when the workspace is created.
In global fallback mode, packages are imported from the original GOPATH
whenthey are not found in the workspace.This is the default import mode for newly created workspaces, as this interferesthe least with existing go tools.
In full isolation mode, package imports will only search in the packages thatare installed inside the workspace.This has some advantages:
However, there's also some downsides to full isolation of a workspace. These areall caused by the fact that the project you're actually working on is not insideyour GOPATH
anymore. So normally go would not be able to find any importsto it. This is partially worked around by locally installing the project intoyour workspace, but it does not fix all issues.
In the sections below the remaining issues are described and you can decide foryourself if the above advantages are worth the disadvantages. If you want to tryout full isolation you can create a new workspace using the --full-isolation
flag:
$ vg init --full-isolation
# To change an existing workspace, you have to destroy and recreate it
$ vg destroy example
$ vg activate example --full-isolation
This will cause the workspace to use full isolation import mode each time it isactivated in the future. So there's no need to specify the--full-isolation
flag on each activation afterwards.
bindfs
installedIf you have bindfs
installed the issues you will runinto are only a slight inconvenience, for which easy workarounds exist. However,it is important that you know about them, because they will probably causeconfusion otherwise. If you run into any other issues than the ones mentionedhere, please report them.
The first set of issues happen when using relative reference to packages incommands. Some examples of this are:
go list ./...
will return weirdly formatted paths, suchas _/home/stream/go/src/github.com/GetStream/vg
.go test ./...
, might cause an init
function to be executed twice.go build ./...
won't work when an internal
package is present in thedirectory. Here you can expect an error saying use of internal package not allowed
.Luckily, this can all easily be worked around by using absolute package pathsfor these commands.So for the vg
repo you would use the following alternatives:
# go list ./...
go list github.com/GetStream/vg/...
# go test ./...
go test github.com/GetStream/vg/...
# go build ./...
go build github.com/GetStream/vg/...
dep
commandsAnother issue that pops up is that dep
doesn't allow it's commands to beexecuted outside of the GOPATH
. This is not a problem for dep ensure
, sinceyou usually use vg ensure
, which handles this automatically. However, this isan issue for other commands, such as dep status
and dep init
. Luckilythere's an easy workaround for this as well. You can simply use vg globalExec
,to execute commands from your regular GOPATH
, which fixes the issue:
vg globalExec dep init
vg globalExec dep status
bindfs
installedIf bindfs
is not installed, symbolic links will be used to do the localinstall.This has the same issues as described for bindfs
, but there's also some extraones that cannot be worked around as easily.The reason for this is that go tooling does not like symbolic links in GOPATH
(golang/go#15507, golang/go#17451).
Compiling will still work, but go list github.com/...
will not list yourpackage. Other than that there are also issues when using delve
(#11). Because of these issues itis NOT RECOMMENDED to use virtualgo in full isolation mode without bindfs
installed.
Because virtualgo is just a usability wrapper around changing your GOPATH
fora specific project it is usually quite easy to use it in combination with anIDE. Just check out your GOPATH
after activating a workspace and configure theIDE accordingly. Usually if you show your GOPATH
you will see two pathsseparated by a colon:
$ echo $GOPATH
/home/stream/.virtualgo/myworkspace:/home/stream/go
If you can set this full string directly that is fine. ForGoLand you have to add the first one first andthen the second one.
When using a workspace in full isolation mode it's even easier to set up asthere's only one GOPATH
set.
$ echo $GOPATH
/home/stream/.virtualgo/myworkspace
MIT
Would you like to work on cool projects like this? We are currently hiring fortalented Gophers in Amsterdam and Boulder, get in touch with us if you areinterested! tommaso@getstream.io
操作系统基于Centos 6.5 Linux ***** 2.6.32-431.el6.x86_64 #1 SMP Fri Nov 22 03:15:09 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux 一. PV(physical volume)即物理卷,就是物理磁盘,可以通过fdisk -l 查看操作系统有几块硬盘 VG(volume group)即卷组,就是一
命令简介: physical volume (pv)物理卷管理命令: pvcreate 创建,pvremove 移除pv上面的数据,pvscan 扫描 pvdisplay 详细查看(pvs查看简单信息), pvmove 移动某pv上数据到别的pv上 命令格式: pvcreat /dev/sda{10,11} pvs查看pv信息 volume group (vg)卷组
VG信息的导出导入 1、umount已经挂载的LV [root@racdb2 ~]# df -h 文件系统 容量 已用 可用 已用% 挂载点 /dev/sda1 18G 14G 2.6G 85% / tmpfs 1.5G 154M 1.4G 11% /dev/shm /dev/mapper/myvg
linux系统下扩容vg大小 几分钟前,我和大家探讨了新增vg如何操作,那么接下来我会和大家聊一下如何把已有的vg进行扩容,基础必会知识,请认真学习~~~~你们的拉菲 1.操作一样,我们还是再添加一块10G的硬盘,我又要吃土了·呜呜呜~~~ 这里添加之后名字是sdb [root@localhost ~]# df -h Filesystem Size Used
在使用virtualbox安装ubuntu时,默认被选中了lvm安装根分区,且根分区比较小。因此磁盘不够用。 扩大ubuntu的ubuntu–vg-ubuntu–lv空间 1 查看根分区空间: root@jack:~# df -h Filesystem Size Used Avail Use% Mounted on udev
1、查看VG属性 root@rzcs:/#vgdisplay -v /dev/vg02 --- Volume groups --- VG Name /dev/vg02 VG Write Access read/write VG Status available Max LV
主要内容:建立卷组,激活卷组,查看卷组,增加卷组容量,减少卷组容量,删除卷组前面章节中,物理分区已经建立,同时也把物理分区建立成了逻辑卷,按照步骤,接下来就建立卷组了。 前面说过,可以把卷组想象成基本分区中的硬盘,是由多个物理卷组成的。卷组就已经可以动态地调整空间大小了,当卷组空间不足时,可以向卷组中添加新的物理卷。 建立卷组 建立卷组使用的命令是 vgcreate,具体命令格式如下: [root@localhost ~]# vgcreate [-s PE 大小] 卷组
问题内容: 我正在使用PyCaffe来实现受VGG 16层网络启发的神经网络。我想使用可从其GitHub页面上获得的预训练模型。通常,这通过匹配图层名称来起作用。 对于我的图层,我的train.prototxt文件中具有以下定义: 这是VGG-16部署体系结构的prototxt文件。请注意,他们的原型中的与我的相同(除了学习率,但这无关紧要)。还值得注意的是,输入在我的模型中也都是相同大小的:3通
问题内容: 根据[本教程](https://towardsdatascience.com/keras-transfer-learning-for- beginners-6c9b8b7143e ),我正在使用转移学习方法在Keras中使用按训练的VGG19模型。它显示了如何训练模型,但没有显示如何为预测准备测试图像。 在评论部分中说: 获取图像,使用相同的函数预处理图像,然后调用。这将为您提供该图像
本文向大家介绍VGG使用3*3卷积核的优势是什么?相关面试题,主要包含被问及VGG使用3*3卷积核的优势是什么?时的应答技巧和注意事项,需要的朋友参考一下 参考回答: 2个33的卷积核串联和55的卷积核有相同的感知野,前者拥有更少的参数。多个3*3的卷积核比一个较大尺寸的卷积核有更多层的非线性函数,增加了非线性表达,使判决函数更具有判决性。
我试图向vgg19网络添加一个密集层,但它给出了以下错误。有人能帮我吗? Python 3.7.0(默认值,2018年6月28日,07:39:16)键入“版权”、“信用”或“许可证”以获取更多信息。 IPython 7.8.0——一种增强的交互式Python。 Runfile('/用户/萨迪克/Dropbox/Moosavi Khorzooghi-04/test', wdir='/用户/萨迪克/D
vgg16\U型号=tf。凯拉斯。应用程序。vgg16.vgg16() 模型=顺序() 对于层vgg16_model.layers[:-1]: model.summary()#去掉最后一个致密层到现在 对于模型中的图层。图层: 模型添加(密集(2,激活='softmax')) model.summary()#现在,当我添加密集层时,模型的可训练参数会发生变化
我的服务器突然空白,我得到以下错误消息在浏览器控制台: 未捕获的TypeError:无法在Vg处读取未定义的react dom.production.min.js:134的属性“current”。。。 会有什么问题?反应CDN服务器有问题? 我在html中的脚本是: 在开发模式下,信息是(来自我的开发环境): (索引):1次访问'https://unpkg.com/react-dom@16.7.0
我目前试图使用的vgg16模型从keras库,但每当我创建一个对象的VGG16模型通过做 我收到以下消息3次。 allocator.cc.124分配的449576960超过10%的系统内存 接下来,我的电脑死机了。我使用一个64位,4GB内存与linux mint 18和我没有访问GPU。 这个问题和我的内存有关吗? 作为一个临时解决方案,我从命令行运行python脚本,因为与任何IDE相比,我的