govendor

Does it make sense to add `go mod vendor` to a pre-commit hook?

拈花ヽ惹草 提交于 2021-02-07 10:59:35
问题 Setup: Our project is using golang 1.12.14 We are using go build -mod=vendor Issue: When new dependencies are added to go.mod the vendor folder isn't updated and people are committing code and forgetting to run go mod vendor to update the folder. My understanding is that since -mod=vendor specifies to use packages from the vendor folder, the go.mod file will have discrepancies from what we are actually using when building the project. Question: Should go mod vendor be added to a pre-commit

vscode 配置 go 开发环境

本秂侑毒 提交于 2020-12-24 01:45:31
一、下载vscode并安装 https://code.visualstudio.com/Download 二、下载go 并安装 https://golang.google.cn/dl/ 三、配置环境 1、配置goroot , 这个是go的安装根目录;gopath,这个是go开发的工作目录 2、 配置 path 3、在cmd 命令中输入go version 和 go env 有如下提示,则说明配置成功 4、在gopath 对应的文件夹下新建 bin、pkg、src三个文件夹,在src下面新建 golang.org/x 文件夹 5、在x文件夹下 ,执行 git clone https://github.com/golang/tools.git tools 和 git clone https://github.com/golang/lint lint 下载github上go相关的工具源码;或者直接去 github 上下载对应的源码,解压并命名为 tools 和 lint 文件下放在 x文件夹下 6、在gopath 对应的文件夹下执行 如下命令,则会在bin目录下,生成对应的exe文件 go install github.com/mdempsky/gocode go install github.com/ramya-rao-a/go-outline go install github

Using `shirou/gopsutil` Go package as a vendored package fails on macOS (10.14.6)

£可爱£侵袭症+ 提交于 2020-08-09 09:12:11
问题 I was trying to build influx/telegraf locally and vendor all the packages using go mod vendor command. However, interestingly, the build fails after that with the following error: # github.com/shirou/gopsutil/host vendor/github.com/shirou/gopsutil/host/host_darwin_cgo.go:9:11: fatal error: 'include/smc.c' file not found #include "include/smc.c" ^~~~~~~~~~~~~~~ Steps to reproduce (after setting GOPATH variable): # Fetch the project, e.g. influx/telegraf go get -d github.com/influxdata/telegraf

Using `shirou/gopsutil` Go package as a vendored package fails on macOS (10.14.6)

假装没事ソ 提交于 2020-08-09 09:11:50
问题 I was trying to build influx/telegraf locally and vendor all the packages using go mod vendor command. However, interestingly, the build fails after that with the following error: # github.com/shirou/gopsutil/host vendor/github.com/shirou/gopsutil/host/host_darwin_cgo.go:9:11: fatal error: 'include/smc.c' file not found #include "include/smc.c" ^~~~~~~~~~~~~~~ Steps to reproduce (after setting GOPATH variable): # Fetch the project, e.g. influx/telegraf go get -d github.com/influxdata/telegraf

golang 第三方包的使用总结

蹲街弑〆低调 提交于 2020-02-29 05:59:47
golang 第三方包的安装的方法: 1. go get 安装 # 比如要安装 "github.com/gin-gonic/gin" $ go get github.com/gin-gonic/gin 注意:执行go get 命令需要先安装git命令,并配置git全局变量。 2. 源码包安装 由于国内网络问题,很多时候go get命令并不能安装,所以就需要手动下载源码包,然后拷贝到$GOPATH/sr/ 目录下 # 比如要安装"github.com/golang/protobuf/proto" # 去github.com/golang/protobuf下载源码包, # 拷贝到 $GOPATH/src/github.com/golang/protobuf $ cd $GOPATH/src/github.com/golang/protobuf $ go install 注意:第三包安装完成后,应用程序导入包时还是使用的源码,而非 $GOPATH/pkg/ 下的 .a文件。如何能像标准包fmt一样直接使用pkg,还需进一步研究。 注意:上面直接写的$GOPATH,在 GOPATH 只有一个目录的时候可以这样写,按tab键就会自动切换为实际目录,如果 GOPATH 配置了多个目录则要输入具体的目录。 golang 使用第三方包 使用方式 在应用程序中直接impor即可 // 比如要使用

Golang gin框架学习记录

我是研究僧i 提交于 2020-02-29 05:35:13
参考文档: Golang 微框架 Gin 简介 https://www.jianshu.com/p/a31e4ee25305 一、使用 Govendor Use a vendor tool like Govendor go get govendor(安装) $ go get github.com/kardianos/govendor Create your project folder and cd inside(创建本地项目目录,并切到该目录下) $ mkdir -p $GOPATH/src/github.com/myusername/project && cd "$_" Vendor init your project and add gin (生成vendor文件以及vendor.json,并下载gin) $ govendor init $ govendor fetch github.com/gin-gonic/gin@v1.2 Copy a starting template inside your project (拷贝 https://raw.githubusercontent.com/gin-gonic/gin/master/examples/basic/main.go 文件到本地,实测本地main.go为空,手动从$GOPATH/src/github.com/gin

How to work with a development vendor package managed by dep?

拥有回忆 提交于 2020-01-23 03:27:05
问题 How can I use a development copy/clone of a package while using dep and a vendor directory? The vendor directory is included in the main repository. For example, I have forked package and replaced it with my own on github. I want to be able to edit the code and not have to git push + dep ensure for each change of the package. If I clone the package in the vendor directory, it I won't be able to commit that directory into the main repo because it's treated as a separate repository. I tried a

Google Container Builder: How to install govendor dependencies during build step?

半腔热情 提交于 2019-12-12 04:08:56
问题 I am trying to use Google Cloud Container Builder to automate the building of my containers using GCP Build Triggers My code is in Go, and I have a vendor folder in my project root which contains all of my Go dependencies (I use govendor ). However, this vendor folder is NOT checked in to source control. I have a cloudbuild.yaml file where I first build my Go source into a main executable, and then build a Docker image using this executable. Container Builder ensures these build steps have

Govendor and dep trying to fetch group, when it should fetch projects

情到浓时终转凉″ 提交于 2019-12-11 06:14:23
问题 I have Go project in gitlab inside a group, so it is like: https://gitlab.com/company/group/project1.git https://gitlab.com/company/group/project2.git etc. I have a vendor folder with vendor.json generated When I call govendor fetch +a # cd .; git clone https://gitlab.com/company/group.git /home/user/go/.cache/govendor/gitlab.com/company/group Cloning into '/home/user/go/.cache/govendor/gitlab.com/company/group'... remote: The project you were looking for could not be found. fatal: repository

How to work with a development vendor package managed by dep?

折月煮酒 提交于 2019-12-04 15:40:13
How can I use a development copy/clone of a package while using dep and a vendor directory? The vendor directory is included in the main repository. For example, I have forked package and replaced it with my own on github. I want to be able to edit the code and not have to git push + dep ensure for each change of the package. If I clone the package in the vendor directory, it I won't be able to commit that directory into the main repo because it's treated as a separate repository. I tried a trick to .gitignore the .git directory from outside the package. This works well until dep ensure is run