Skip to content

Instantly share code, notes, and snippets.

@simoneau
Created February 4, 2020 18:17
Show Gist options
  • Save simoneau/723061f8d2646f2ccf059308305f933e to your computer and use it in GitHub Desktop.
Save simoneau/723061f8d2646f2ccf059308305f933e to your computer and use it in GitHub Desktop.
Wrong version of dependency
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")
load("@bazel_gazelle//:def.bzl", "gazelle")
# gazelle:prefix example.com/testo
gazelle(name = "gazelle")
go_library(
name = "go_default_library",
srcs = ["main.go"],
importpath = "example.com/testo",
visibility = ["//visibility:private"],
deps = ["@com_github_pelletier_go_toml//:go_default_library"],
)
go_binary(
name = "testo",
embed = [":go_default_library"],
visibility = ["//visibility:public"],
)
module exmaple.com/testo
go 1.13
require github.com/pelletier/go-toml v1.6.0
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/pelletier/go-toml v1.6.0 h1:aetoXYr0Tv7xRU/V4B4IZJ2QcbtMUFoNb3ORp7TzIK4=
github.com/pelletier/go-toml v1.6.0/go.mod h1:5N711Q9dKgbdkxHL+MEfF31hpT7l0S0s/t2kKREewys=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
package main
import (
"log"
"os"
"time"
"github.com/pelletier/go-toml"
)
func main() {
f, err := os.Open("testo.yml")
if err != nil {
log.Fatal("failed!")
}
type C struct {
D time.Duration
}
var c C
decoder := toml.NewDecoder(f)
decoder.Decode(&c)
log.Print(c.D.String())
}
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "io_bazel_rules_go",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.21.2/rules_go-v0.21.2.tar.gz",
"https://github.com/bazelbuild/rules_go/releases/download/v0.21.2/rules_go-v0.21.2.tar.gz",
],
sha256 = "f99a9d76e972e0c8f935b2fe6d0d9d778f67c760c6d2400e23fc2e469016e2bd",
)
load("@io_bazel_rules_go//go:deps.bzl", "go_rules_dependencies", "go_register_toolchains")
go_rules_dependencies()
go_register_toolchains()
http_archive(
name = "bazel_gazelle",
urls = [
"https://storage.googleapis.com/bazel-mirror/github.com/bazelbuild/bazel-gazelle/releases/download/v0.19.1/bazel-gazelle-v0.19.1.tar.gz",
"https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.19.1/bazel-gazelle-v0.19.1.tar.gz",
],
sha256 = "86c6d481b3f7aedc1d60c1c211c6f76da282ae197c3b3160f54bd3a8f847896f",
)
load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies")
gazelle_dependencies()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment