Skip to content

Instantly share code, notes, and snippets.

@yihuang
Last active September 27, 2020 04:01
Show Gist options
  • Save yihuang/7e9e3cfb5ab3f126f077c1e5b66002ad to your computer and use it in GitHub Desktop.
Save yihuang/7e9e3cfb5ab3f126f077c1e5b66002ad to your computer and use it in GitHub Desktop.
ultimate go module major version test case
# file generated from go.mod using vgo2nix (https://github.com/adisbladis/vgo2nix)
[
{
goPackagePath = "github.com/cespare/xxhash/v2";
fetch = {
type = "git";
url = "https://github.com/yihuang/test-golang-module-major-version";
rev = "4a13e4bfd5a9";
sha256 = "0i1bpw3v73jhwnpa8vv276qhy39fk6qhgyci0wng9mwr2pxfha5y";
moduleDir = "";
};
}
{
goPackagePath = "github.com/yihuang/test-golang-module-major-version";
fetch = {
type = "git";
url = "https://github.com/yihuang/test-golang-module-major-version";
rev = "v1.0.1";
sha256 = "10gnzs3l8j6skyrfi2blvqx9b3l2bs2gdvrgjg7a9aiz6z7dkpvy";
moduleDir = "";
};
}
{
goPackagePath = "github.com/yihuang/test-golang-module-major-version/sub";
fetch = {
type = "git";
url = "https://github.com/yihuang/test-golang-module-major-version";
rev = "sub/v1.0.2";
sha256 = "0g89fd75mhfyxgw2ip69idaf14586l9birq0kz59mdpak1ywr0k8";
moduleDir = "";
};
}
{
goPackagePath = "github.com/yihuang/test-golang-module-major-version/sub/v2";
fetch = {
type = "git";
url = "https://github.com/yihuang/test-golang-module-major-version";
rev = "sub/v2.0.1";
sha256 = "026cfk2bpc7cyddabj8fcay3nysbj9zjam63jbq8psav4qwhwc2d";
moduleDir = "";
};
}
{
goPackagePath = "github.com/yihuang/test-golang-module-major-version/v2";
fetch = {
type = "git";
url = "https://github.com/yihuang/test-golang-module-major-version";
rev = "v2.0.1";
sha256 = "026cfk2bpc7cyddabj8fcay3nysbj9zjam63jbq8psav4qwhwc2d";
moduleDir = "";
};
}
{
goPackagePath = "gopkg.in/check.v1";
fetch = {
type = "git";
url = "https://gopkg.in/check.v1";
rev = "20d25e280405";
sha256 = "0k1m83ji9l1a7ng8a7v40psbymxasmssbrrhpdv2wl4rhs0nc3np";
moduleDir = "";
};
}
{
goPackagePath = "gopkg.in/yaml.v2";
fetch = {
type = "git";
url = "https://gopkg.in/yaml.v2";
rev = "v2.3.0";
sha256 = "1md0hlyd9s6myv3663i9l59y74n4xjazifmmyxn43g86fgkc5lzj";
moduleDir = "";
};
}
]
module testmod
go 1.15
require github.com/yihuang/test-golang-module-major-version v1.0.1
require github.com/yihuang/test-golang-module-major-version/v2 v2.0.1
require github.com/yihuang/test-golang-module-major-version/sub v1.0.2
require github.com/yihuang/test-golang-module-major-version/sub/v2 v2.0.1
require (
github.com/cespare/xxhash/v2 v2.1.1
gopkg.in/yaml.v2 v2.3.0
)
replace github.com/cespare/xxhash/v2 v2.1.1 => github.com/yihuang/test-golang-module-major-version/v2 v2.0.2-0.20200924181748-4a13e4bfd5a9
package main
import (
"fmt"
replaced "github.com/cespare/xxhash/v2"
v1 "github.com/yihuang/test-golang-module-major-version"
"gopkg.in/yaml.v2"
v1_sub "github.com/yihuang/test-golang-module-major-version/sub"
v2_sub "github.com/yihuang/test-golang-module-major-version/sub/v2"
v2 "github.com/yihuang/test-golang-module-major-version/v2"
)
func main() {
fmt.Println(v1.Test(), v2.Test(), v1_sub.Test(), v2_sub.Test(), replaced.Test())
fmt.Println(yaml.Marshal(1))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment