This is a creation in Article, where the information may have evolved or changed. > View Original text: [Blog.keyboardman.me] (https://blog.keyboardman.me/2018/02/23/early-adopters-versioned-go/) has been, There is not a good solution for go-dependent package versioning, there are currently two main ways to ' Import Versioning ' and ' Semantic Versioning '. * Import Versioning: ' gopkg.in ' website, in fact, is a change of GitHub version of the redirector, you can through the ' gopkg.in/yaml.v1 ' and ' gopkg.in/yaml.v2 ' The import way to point to the different commit versions of the GIT library * Semantic Versioning: A file format specification was developed to describe the exact source and version information (DEP, glide) of the code in the Management Vendor directory (2018-02-20) days before Russ The Cox Blog introduces his new tool ' VGo ' for Go, which is a replacement for the Go tool designed to handle the package version, vgo the versioned go abbreviation, meaning the version of Go. VGO is currently only running on go1.10, otherwise it will get ' vgo objabi:cannot find gomips ' error. Install VGo first. "' Bashgo get-u golang.org/x/vgo ', let's try it first, then [official example] (https://research.swtch.com/vgo-tour). "' Bashmkdir $GOPATH/src/hellocd $GOPATH/src/hellocurl-ss https://swtch.com/hello.go > Hello.go ' ' Let's see ' Hello.go ' The content. "' Gopackage Main//import" Github.com/you/hello "Import (" FMT "" Rsc.io/quote ") func main () {FMT. Println (quote. Hello ())} "where the '//import ' Github.com/you/hello ' comment is used to tell the VGO module what the ' Import path name ' should be, and the other packages using this module will be used as the import identifier. Create an empty Go.mod file to mark the root of this project, and then edit theTranslate it, please. ' Bashecho >go.modvgo build ' can see the build executable and modify the ' go.mod ' content, automatically generating dependencies. "Bashmodule" Github.com/you/hello "Require" rsc.io/quote "v1.5.2" ' Go.mod ' file contains the minimum version of the package that the module depends on. If the module does not provide a ' tag ' version. For unnamed commits, ' V0.0.0-yyyymmddhhmmss-commit ' represents a commit of a specified date. The ' go.mod ' file can also be used to implement the excluded and replaced versions, and the ' go.mod ' files need to be modified manually. "Bashexclude" Rsc.io/sampler "V1.99.99replace" rsc.io/quote "v1.5.2 =". /quote "" However, the most important change is to end the ' Gopath ' as the setting for the Go Code workspace, because the ' go.mod ' file contains the full module path and also defines each dependent version used, so it contains ' go.mod ' The directory of a file can be considered to be the root of a directory tree, which acts on its own workspace and is isolated from other similar directories. VGo Other Features ' bashvgo list-m # View all dependent vgo list-m-U # View all dependencies check for updates at the same time, print out the latest version and current version vgo Test all # Perform all tests, including dependent package tests VGO test http:/ /rsc.io/sampler # Execute the specified package test vgo get-u # Update all dependencies vgo list-t Http://rsc.io/sampler # Check that all available versions of the specified package are tagvgo get Http://rsc.io/sam pler@v1.3.1 # Gets the specified version and modifies the GO.MODVGO vendor # to fall back to vendor compatible users who do not use vgo ... "vgo when downloading the GitHub repository, if the current environment is an unauthenticated account will be affected by throttling, get the following warning. "' Bashgithub applies fairly small rate limits to unauthenticated users, andyou appear to be hitting them. To authenticate, please VisiThttps://github.com/settings/tokens and click "Generate New token" tocreate a Personal Access Token. The token is only needs "Public_repo" scope, but can add "repo" if you want to access privaterepositories too. "This time need to get GI Thub token, click on the GitHub website ' Settings '-' Developer Settings '-' Personal access tokens '-' Generate new token ', Generate tokens by filling in the name and selecting the permission. Create or modify the ' $HOME/.netrc ' file, add the following line, fill in the generated tokens, and you will be able to solve them. "' Bashmachine api.github.com Login You password TOKEN ' is not perfect for vgo, the code is not strong enough and may not be suitable for use in the production environment. I encountered some problems during the test, such as having a ' gopkg.in ' warehouse that uses tags instead of branches to mark major versions. The current VGO handles these warehouses with errors. "' Goimport (_" Gopkg.in/natefinch/lumberjack.v2 ") will get the following error. "' Bashimport" gopkg.in/natefinch/lumberjack.v2 ": Unexpected status (https://api.github.com/repos/natefinch/ lumberjack/commits?sha=v2&until=2018-02-23t03%3a49%3a22z&per_page=2): 404 Not Found# or Vgo:import "gopkg.in/ Natefinch/lumberjack.v2 ": Unexpected Status (https://api.github.com/repos/natefinch/lumberjack): 403 Forbidden '" But vgo should fix these problems soon. 1538 reads
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.