1651188000
Goop
A dependency manager for Go (golang), inspired by Bundler. It is different from other dependency managers in that it does not force you to mess with your GOPATH
.
Install Goop: go get github.com/nitrous-io/goop
Create Goopfile
. Revision reference (e.g. Git SHA hash) is optional, but recommended. Prefix hash with #
. (This is to futureproof the file format.)
Example:
github.com/mattn/go-sqlite3
github.com/gorilla/context #14f550f51af52180c2eefed15e5fd18d63c0a64a
github.com/dotcloud/docker/pkg/proxy #v1.0.1 // comment
github.com/gorilla/mux !git@github.com:nitrous-io/mux.git // override repo url
Run goop install
. This will install packages inside a subdirectory called .vendor
and create Goopfile.lock
, recording exact versions used for each package and its dependencies. Subsequent goop install
runs will ignore Goopfile
and install the versions specified in Goopfile.lock
. You should check this file in to your source version control. It's a good idea to add .vendor
to your version control system's ignore settings (e.g. .gitignore
).
Run commands using goop exec
(e.g. goop exec make
). This will execute your command in an environment that has correct GOPATH
and PATH
set.
Go commands can be run without the exec
keyword (e.g. goop go test
).
Run goop update
to ignore an existing Goopfile.lock
, and update to latest versions of packages (as specified in Goopfile
).
Running eval $(goop env)
will modify GOPATH
and PATH
in current shell session, allowing you to run commands without goop exec
.
Goop currently only supports Git and Mercurial. This should be fine for 99% of the cases, but you are more than welcome to make a pull request that adds support for Subversion and Bazaar.
Work on awesome golang projects, like Goop, at Nitrous.IO
Copyright (c) 2014 Irrational Industries, Inc. d.b.a. Nitrous.IO.
Author: Petejkim
Source Code: https://github.com/petejkim/goop
License: MIT License
1651188000
Goop
A dependency manager for Go (golang), inspired by Bundler. It is different from other dependency managers in that it does not force you to mess with your GOPATH
.
Install Goop: go get github.com/nitrous-io/goop
Create Goopfile
. Revision reference (e.g. Git SHA hash) is optional, but recommended. Prefix hash with #
. (This is to futureproof the file format.)
Example:
github.com/mattn/go-sqlite3
github.com/gorilla/context #14f550f51af52180c2eefed15e5fd18d63c0a64a
github.com/dotcloud/docker/pkg/proxy #v1.0.1 // comment
github.com/gorilla/mux !git@github.com:nitrous-io/mux.git // override repo url
Run goop install
. This will install packages inside a subdirectory called .vendor
and create Goopfile.lock
, recording exact versions used for each package and its dependencies. Subsequent goop install
runs will ignore Goopfile
and install the versions specified in Goopfile.lock
. You should check this file in to your source version control. It's a good idea to add .vendor
to your version control system's ignore settings (e.g. .gitignore
).
Run commands using goop exec
(e.g. goop exec make
). This will execute your command in an environment that has correct GOPATH
and PATH
set.
Go commands can be run without the exec
keyword (e.g. goop go test
).
Run goop update
to ignore an existing Goopfile.lock
, and update to latest versions of packages (as specified in Goopfile
).
Running eval $(goop env)
will modify GOPATH
and PATH
in current shell session, allowing you to run commands without goop exec
.
Goop currently only supports Git and Mercurial. This should be fine for 99% of the cases, but you are more than welcome to make a pull request that adds support for Subversion and Bazaar.
Work on awesome golang projects, like Goop, at Nitrous.IO
Copyright (c) 2014 Irrational Industries, Inc. d.b.a. Nitrous.IO.
Author: Petejkim
Source Code: https://github.com/petejkim/goop
License: MIT License
1599854400
Go announced Go 1.15 version on 11 Aug 2020. Highlighted updates and features include Substantial improvements to the Go linker, Improved allocation for small objects at high core counts, X.509 CommonName deprecation, GOPROXY supports skipping proxies that return errors, New embedded tzdata package, Several Core Library improvements and more.
As Go promise for maintaining backward compatibility. After upgrading to the latest Go 1.15 version, almost all existing Golang applications or programs continue to compile and run as older Golang version.
#go #golang #go 1.15 #go features #go improvement #go package #go new features
1663417920
In today's post we will learn about 10 Popular Go Libraries for Package & Dependency Management.
What is dependency management?
Dependency management is the process of managing all of these interrelated tasks and resources to ensure that your overall project completes successfully, on time, and on budget. When there are dependencies that need to be managed between projects, it's referred to as project interdependency management.
Table of contents:
Manage your golang vendor and vendored packages with ease. Inspired by tools like Maven, Bundler, and Pip.
Are you used to tools such as Cargo, npm, Composer, Nuget, Pip, Maven, Bundler, or other modern package managers? If so, Glide is the comparable Go tool.
Manage your vendor and vendored packages with ease. Glide is a tool for managing the vendor
directory within a Go package. This feature, first introduced in Go 1.5, allows each package to have a vendor
directory containing dependent packages for the project. These vendor packages can be installed by a tool (e.g. glide), similar to go get
or they can be vendored and distributed with the package.
The Go community is now using Go Modules to handle dependencies. Please consider using that instead of Glide. Glide is now mostly unmaintained.
github.com/Masterminds/semver
package can parse can be used.go
toolsGlide scans the source code of your application or library to determine the needed dependencies. To determine the versions and locations (such as aliases for forks) Glide reads a glide.yaml
file with the rules. With this information Glide retrieves needed dependencies.
When a dependent package is encountered its imports are scanned to determine dependencies of dependencies (transitive dependencies). If the dependent project contains a glide.yaml
file that information is used to help determine the dependency rules when fetching from a location or version to use. Configuration from Godep, GB, GOM, and GPM is also imported.
The dependencies are exported to the vendor/
directory where the go
tools can find and use them. A glide.lock
file is generated containing all the dependencies, including transitive ones.
The glide init
command can be use to setup a new project, glide update
regenerates the dependency versions using scanning and rules, and glide install
will install the versions listed in the glide.lock
file, skipping scanning, unless the glide.lock
file is not found in which case it will perform an update.
A project is structured like this:
- $GOPATH/src/myProject (Your project)
|
|-- glide.yaml
|
|-- glide.lock
|
|-- main.go (Your main go code can live here)
|
|-- mySubpackage (You can create your own subpackages, too)
| |
| |-- foo.go
|
|-- vendor
|-- github.com
|
|-- Masterminds
|
|-- ... etc.
Take a look at the Glide source code to see this philosophy in action.
The easiest way to install the latest release on Mac or Linux is with the following script:
curl https://glide.sh/get | sh
On Mac OS X you can also install the latest release via Homebrew:
$ brew install glide
On Ubuntu Precise (12.04), Trusty (14.04), Wily (15.10) or Xenial (16.04) you can install from our PPA:
sudo add-apt-repository ppa:masterminds/glide && sudo apt-get update
sudo apt-get install glide
On Ubuntu Zesty (17.04) the package is called golang-glide
.
Binary packages are available for Mac, Linux and Windows.
For a development version it is also possible to go get github.com/Masterminds/glide
.
To build from source you can:
$GOPATH/src/github.com/Masterminds/glide
and change directory into itexport GO15VENDOREXPERIMENT=1
. In Go 1.6 it is enabled by default and in Go 1.7 it is always enabled without the ability to turn it off.make build
This will leave you with ./glide
, which you can put in your $PATH
if you'd like. (You can also take a look at make install
to install for you.)
The Glide repo has now been configured to use glide to manage itself, too.
Dependency tool for go, godep helps build packages reproducibly by fixing their dependencies.
The Go community now has the dep project to manage dependencies. Please consider trying to migrate from Godep to dep. If there is an issue preventing you from migrating please file an issue with dep so the problem can be corrected. Godep will continue to be supported for some time but is considered to be in a state of support rather than active feature development.
go get github.com/tools/godep
Assuming you've got everything working already, so you can build your project with go install
and test it with go test
, it's one command to start using:
godep save
This will save a list of dependencies to the file Godeps/Godeps.json
and copy their source code into vendor/
(or Godeps/_workspace/
when using older versions of Go). Godep does not copy:
*_test.go
files.testdata
directories.Godep does not process the imports of .go
files with either the ignore
or appengine
build tags.
Test files and testdata directories can be saved by adding -t
.
Read over the contents of vendor/
and make sure it looks reasonable. Then commit the Godeps/
and vendor/
directories to version control.
-r
flagFor older versions of Go, the -r
flag tells save to automatically rewrite package import paths. This allows your code to refer directly to the copied dependencies in Godeps/_workspace
. So, a package C that depends on package D will actually import C/Godeps/_workspace/src/D
. This makes C's repo self-contained and causes go get
to build C with the right version of all dependencies.
If you don't use -r
, when using older version of Go, then in order to use the fixed dependencies and get reproducible builds, you must make sure that every time you run a Go-related command, you wrap it in one of these two ways:
go
, run it as godep go ...
, e.g. godep go install -v ./...
$GOPATH
using godep path
as described below.-r
isn't necessary with go1.6+ and isn't allowed.
Go Manager - bundle for go.
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.
go get github.com/mattn/gom
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
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>
Simple dependency manager for Go (golang), inspired by Bundler.
A dependency manager for Go (golang), inspired by Bundler. It is different from other dependency managers in that it does not force you to mess with your GOPATH
.
Install Goop: go get github.com/nitrous-io/goop
Create Goopfile
. Revision reference (e.g. Git SHA hash) is optional, but recommended. Prefix hash with #
. (This is to futureproof the file format.)
Example:
github.com/mattn/go-sqlite3
github.com/gorilla/context #14f550f51af52180c2eefed15e5fd18d63c0a64a
github.com/dotcloud/docker/pkg/proxy #v1.0.1 // comment
github.com/gorilla/mux !git@github.com:nitrous-io/mux.git // override repo url
Run goop install
. This will install packages inside a subdirectory called .vendor
and create Goopfile.lock
, recording exact versions used for each package and its dependencies. Subsequent goop install
runs will ignore Goopfile
and install the versions specified in Goopfile.lock
. You should check this file in to your source version control. It's a good idea to add .vendor
to your version control system's ignore settings (e.g. .gitignore
).
Run commands using goop exec
(e.g. goop exec make
). This will execute your command in an environment that has correct GOPATH
and PATH
set.
Go commands can be run without the exec
keyword (e.g. goop go test
).
Run goop update
to ignore an existing Goopfile.lock
, and update to latest versions of packages (as specified in Goopfile
).
Running eval $(goop env)
will modify GOPATH
and PATH
in current shell session, allowing you to run commands without goop exec
.
Goop currently only supports Git and Mercurial. This should be fine for 99% of the cases, but you are more than welcome to make a pull request that adds support for Subversion and Bazaar.
Build and manage your Go applications out of GOPATH.
GOP is a project manangement tool for building your golang applications out of global GOPATH. In fact gop will keep both global GOPATH and every project GOPATH. But that means your project will not go-getable. Of course, GOP itself is go-getable. GOP copy all denpendencies from global GOPATH to your project's src/vendor
directory and all application's sources are also in src
directory.
A normal process using gop is below:
git clone xxx@mydata.com:bac/aaa.git
cd aaa
gop ensure -g
gop build
gop test
Please ensure you have installed the go
command, GOP will invoke it on building or testing
go get github.com/lunny/gop
Every project should have a GOPATH directory structure and put a gop.yml
int the root directory. This is an example project's directory tree.
<project root>
├── gop.yml
├── bin
├── doc
└── src
├── main
│ └── main.go
├── models
│ └── models.go
├── routes
│ └── routes.go
└── vendor
└── github.com
├── go-xorm
│ ├── builder
│ ├── core
│ └── xorm
└── lunny
├── log
└── tango
Go Package Manager.
Gopm (Go Package Manager) is a Go package manage and build tool for Go.
go get -u github.com/gpmgo/gopm
The executable will be produced under $GOPATH/bin
in your file system; for global use purpose, we recommend you to add this path into your PATH
environment variable.
git
or hg
in order to download packages.gopm build
or gopm install
, everything just happens in its own GOPATH and does not bother anything you've done (unless you told it to)..gopmfile
).NAME:
Gopm - Go Package Manager
USAGE:
Gopm [global options] command [command options] [arguments...]
COMMANDS:
list list all dependencies of current project
gen generate a gopmfile for current Go project
get fetch remote package(s) and dependencies
bin download and link dependencies and build binary
config configure gopm settings
run link dependencies and go run
test link dependencies and go test
build link dependencies and go build
install link dependencies and go install
clean clean all temporary files
update check and update gopm resources including itself
help, h Shows a list of commands or help for one command
GLOBAL OPTIONS:
--noterm, -n disable color output
--strict, -s strict mode
--debug, -d debug mode
--help, -h show help
--version, -v print the version
Plugin that provides way for auto-loading of Golang SDK, dependency management and start build environment in Maven project infrastructure.
GO start!
Taste Go in just two commands!
mvn archetype:generate -B -DarchetypeGroupId=com.igormaznitsa -DarchetypeArtifactId=mvn-golang-hello -DarchetypeVersion=2.3.10 -DgroupId=com.go.test -DartifactId=gohello -Dversion=1.0-SNAPSHOT
mvn -f ./gohello/pom.xml package
The First command in th snippet above generates a maven project with some test files and the second command builds the project. Also you can take a look at the example Hello world
project using the plugin
If you want to generate a multi-module project, then you can use such snippet
mvn archetype:generate -B -DarchetypeGroupId=com.igormaznitsa -DarchetypeArtifactId=mvn-golang-hello-multi -DarchetypeVersion=2.3.10 -DgroupId=com.go.test -DartifactId=gohello-multi -Dversion=1.0-SNAPSHOT
Introduction
The Plug-in just wraps Golang tool-chain and allows to use strong maven based infrastructure to build Golang projects. It also can automatically download needed Golang SDK from the main server and tune needed version of packets for their branch, tag or revisions. Because a Golang project in the case is formed as just maven project, it is possible to work with it in any Java IDE which supports Maven.
How it works
On start the plug-in makes below steps:
bin/go
with defined command, the source folder will be set as current folderHow to build
Because it is maven plugin, to build the plugin just use
mvn clean install -Pplugin
To save time, examples excluded from the main build process and activated through special profile
mvn clean install -Pexamples
Barebones dependency manager for Go.
Go Package Manager (or gpm, for short) is a tool that helps achieve reproducible builds for Go applications by specifying the revision of each external Go package that the application depends on.
Being simple and unobstrusive are some of the most important design choices for gpm: go get
already provides a way to fetch dependencies, and relies on versions control systems like Git to do it, gpm adds the additional step of setting each dependency repo to the desired revision, neither Go or your application even know about any of this happening, it just works.
To achieve this, gpm uses a manifest file which is assumed to be called Godeps
(although you can name it however you want), running gpm fetches all dependencies and ensures each is set to a specified version, down to revision level.
For a given project, running gpm
in the directory containing the Godeps
file is enough to make sure dependencies in the file are fetched and set to the correct revision.
However, if you share your GOPATH
with other projects running gpm each time can get old, my solution for that is to isolate dependencies by manipulating the GOPATH
, see the workspaces section for details.
You can see gpm in action under this workflow in the following gif:
$ brew install gpm
$ yaourt -S go-gpm
or
$ packer -S go-gpm
Caveat: you'll use go-gpm
instead of just gpm
in the command line, as there is a general purpose linux package under that name already.
Minimal dependency version using Git.
Johnny Deps is a small tool from VividCortex that provides minimalistic dependency versioning for Go repositories using Git. Its primary purpose is to help create reproducible builds when many import paths in various repositories are required to build an application. It's based on a Perl script that provides subcommands for retrieving or building a project, or updating a dependencies file (called Godeps
), listing first-level imports for a project.
Install Johnny Deps by cloning the project's Github repository and running the provided scripts, like this:
git clone https://github.com/VividCortex/johnny-deps.git
cd johnny-deps
./configure --prefix=/your/path
make install
The --prefix
option to configure
is not mandatory; it defaults to /usr/local
if not provided (but you'd have to install as root in that case). The binary will end up at the bin
subdirectory, under the prefix you choose; make sure you have that location specified in your PATH
.
Note that Perl is required, although that's probably provided by your system already. Also Go, Git and (if you're using makefiles) Make.
Johnny Deps is all about project dependencies. Each project should have a file called Godeps at its root, listing the full set of first-level dependencies; i.e., all repositories with Go packages imported directly by this project. The file may be omitted when empty and looks like this:
github.com/VividCortex/godaemon 2fdf3f9fa715a998e834f09e07a8070d9046bcfd
github.com/VividCortex/log 1ffbbe58b5cf1bcfd7a80059dd339764cc1e3bff
github.com/VividCortex/mysql f82b14f1073afd7cb41fc8eb52673d78f481922e
The first column identifies the dependency. The second is the commit identifier for the exact revision the current project depends upon. You can use any identifier Git would accept to checkout, including abbreviated commits, tags and branches. Note, however, that the use of branches is discouraged, cause it leads to non-reproducible builds as the tip of the branch moves forward.
jd
is Johnny Deps' main binary. It's a command line tool to retrieve projects from Github, check dependencies, reposition local working copies according to each project's settings, building and updating. It accepts subcommands much like go
or git
do:
jd [global-options] [command] [options] [project]
Global options apply to all commands. Some allow you to change the external tools that are used (go, git and make) in case you don't have them in your path, or otherwise want to use a different version. There's also a -v
option to increase verbosity, that you can provide twice for extra effect. (Note that the tool runs silently by default, only displaying errors, if any.)
It's worth noting that all parameters are optional. If you don't specify a command, it will default to build
(see "Building" below). If you don't specify a project, jd
will try to infer the project based on your current working path, and your setting for GOPATH
. If you're in a subdirectory of any of the GOPATH
components, and you're also in a Git working tree, jd
would be happy to fill up the project for you.
When in doubt, check jd help
.
Converts 'go mod graph' output into Graphviz's DOT language.
Converts 'go mod graph' output into GraphViz's DOT language.
go mod graph | modgv | dot -Tpng -o graph.png
For each module:
go get github.com/lucasepe/modgv/modgv
Here 👉 https://graphviz.gitlab.io/download/ how to install GraphViz for your OS.
go mod graph | modgv | dot -Tpng -o graph.png
go mod graph | modgv | dot -Tps2 -o graph.ps
ps2pdf graph.ps graph.pdf
Thank you for following this article.
Learning Golang: Dependencies, Modules and How to manage Packages
1655304840
Building Web Applications with Go
Welcome, gopher! You're not a gopher? Well, this workshop is for gophers, or people that use the Go programming language. But fear not if you've never written any Go before! I'd recommend you learn the basics for the language first with the Go tour.
This workshop has been run a couple of times with an instructor leading. The goal of this repo is to make it as easy as possible for individuals to follow the content by themselves. If you get stuck at any point, feel free to file issues asking questions.
To go through this you will need the following:
GOPATH
by following the How to Write Go Code tutorial.There's a lot to say about how to build web applications, in Go or any other language. But we only have one day so we won't try to cover too much. Instead we'll cover the basics, so you'll be able to explore other solutions and frameworks later.
The workshops is divided in eleven sections:
These are places where you can find more information for Go:
My favorite aspect of Go is its community, and you are now part of it too. Welcome!
As a newcomer to the Go community you might have questions or get blocked at some point. This is completely normal, and we're here to help you. Some of the places where gophers tend to hang out are:
This is not an official Google product (experimental or otherwise), it is just code that happens to be owned by Google.
Author: Campoy
Source Code: https://github.com/campoy/go-web-workshop
License: Apache-2.0 license
1599732000
We spoke to Rob Pike, the co-author of the Go programming language, about a career spanning four decades, the evolution of Go over the last ten years, and into the future.
Evrone: Unlike many developers today, you started your career decades ago at Bell Labs. What’s been the biggest change in the way we develop software that you can think of, given your rare perspective?
**Rob: **The scale is much bigger today. Not just of the computers and the network, but the programs themselves. All of Unix version 6 (circa 1975) fits comfortably on a single RK05 disk pack, which has just over 2MB of storage, with lots of room left over for user software. And that was a fine computing environment, or at least seemed like one at the time. Although I can, of course, explain much of the growth, it is astonishing and perhaps not all of it is justified.
#golang #golang-api #golang-tools #golang-website #rob-pike #interview-transcript-go #latest-tech-stories #cloud-infrastructure-and-go