diff -Nru golang-github-containerd-typeurl-1.0.1/debian/changelog golang-github-containerd-typeurl-1.0.2/debian/changelog --- golang-github-containerd-typeurl-1.0.1/debian/changelog 2020-08-23 13:34:50.000000000 +0000 +++ golang-github-containerd-typeurl-1.0.2/debian/changelog 2021-10-09 18:01:59.000000000 +0000 @@ -1,3 +1,12 @@ +golang-github-containerd-typeurl (1.0.2-1) unstable; urgency=medium + + * Team upload. + * New upstream version 1.0.2 + * Update Section to golang + * Update Standards-Version to 4.6.0 (no changes) + + -- Shengjing Zhu Sun, 10 Oct 2021 02:01:59 +0800 + golang-github-containerd-typeurl (1.0.1-1) unstable; urgency=low * Team upload. diff -Nru golang-github-containerd-typeurl-1.0.1/debian/control golang-github-containerd-typeurl-1.0.2/debian/control --- golang-github-containerd-typeurl-1.0.1/debian/control 2020-08-23 13:34:50.000000000 +0000 +++ golang-github-containerd-typeurl-1.0.2/debian/control 2021-10-09 18:01:59.000000000 +0000 @@ -1,5 +1,5 @@ Source: golang-github-containerd-typeurl -Section: devel +Section: golang Priority: optional Maintainer: Debian Go Packaging Team Uploaders: Arnaud Rebillout , @@ -8,7 +8,7 @@ golang-any, golang-github-gogo-protobuf-dev (>= 0.5~), golang-github-pkg-errors-dev, -Standards-Version: 4.5.0 +Standards-Version: 4.6.0 Homepage: https://github.com/containerd/typeurl Vcs-Browser: https://salsa.debian.org/go-team/packages/golang-github-containerd-typeurl Vcs-Git: https://salsa.debian.org/go-team/packages/golang-github-containerd-typeurl.git diff -Nru golang-github-containerd-typeurl-1.0.1/debian/watch golang-github-containerd-typeurl-1.0.2/debian/watch --- golang-github-containerd-typeurl-1.0.1/debian/watch 2020-08-23 13:34:50.000000000 +0000 +++ golang-github-containerd-typeurl-1.0.2/debian/watch 2021-10-09 18:01:59.000000000 +0000 @@ -1,4 +1,4 @@ -version=3 -opts=filenamemangle=s/.+\/v?(\d\S*)\.tar\.gz/golang-github-containerd-typeurl-\$1\.tar\.gz/,\ -uversionmangle=s/(\d)[_\.\-\+]?(RC|rc|pre|dev|beta|alpha)[.]?(\d*)$/\$1~\$2\$3/ \ - https://github.com/containerd/typeurl/tags .*/v?(\d\S*)\.tar\.gz +version=4 +opts="mode=git, pgpmode=none" \ + https://github.com/containerd/typeurl \ + refs/tags/v?@ANY_VERSION@ debian diff -Nru golang-github-containerd-typeurl-1.0.1/.github/workflows/ci.yml golang-github-containerd-typeurl-1.0.2/.github/workflows/ci.yml --- golang-github-containerd-typeurl-1.0.1/.github/workflows/ci.yml 2020-04-13 18:06:23.000000000 +0000 +++ golang-github-containerd-typeurl-1.0.2/.github/workflows/ci.yml 2021-03-18 03:27:13.000000000 +0000 @@ -1,4 +1,4 @@ -name: Go +name: CI on: push: @@ -14,17 +14,17 @@ timeout-minutes: 5 steps: - - name: Set up Go 1.13 - uses: actions/setup-go@v1 + - name: Set up Go 1.16 + uses: actions/setup-go@v2 with: - go-version: 1.13 + go-version: 1.16.x id: go - name: Setup Go binary path shell: bash run: | - echo "::set-env name=GOPATH::${{ github.workspace }}" - echo "::add-path::${{ github.workspace }}/bin" + echo "GOPATH=${{ github.workspace }}" >> $GITHUB_ENV + echo "${{ github.workspace }}/bin" >> $GITHUB_PATH - name: Check out code uses: actions/checkout@v2 diff -Nru golang-github-containerd-typeurl-1.0.1/go.mod golang-github-containerd-typeurl-1.0.2/go.mod --- golang-github-containerd-typeurl-1.0.1/go.mod 2020-04-13 18:06:23.000000000 +0000 +++ golang-github-containerd-typeurl-1.0.2/go.mod 2021-03-18 03:27:13.000000000 +0000 @@ -3,6 +3,6 @@ go 1.13 require ( - github.com/gogo/protobuf v1.3.1 + github.com/gogo/protobuf v1.3.2 github.com/pkg/errors v0.9.1 ) diff -Nru golang-github-containerd-typeurl-1.0.1/go.sum golang-github-containerd-typeurl-1.0.2/go.sum --- golang-github-containerd-typeurl-1.0.1/go.sum 2020-04-13 18:06:23.000000000 +0000 +++ golang-github-containerd-typeurl-1.0.2/go.sum 2021-03-18 03:27:13.000000000 +0000 @@ -1,7 +1,33 @@ -github.com/gogo/protobuf v1.3.1 h1:DqDEcV5aeaTmdFBePNpYsp3FlcVH/2ISVVM9Qf8PSls= -github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o= -github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00= +github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= +github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= +github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= diff -Nru golang-github-containerd-typeurl-1.0.1/README.md golang-github-containerd-typeurl-1.0.2/README.md --- golang-github-containerd-typeurl-1.0.1/README.md 2020-04-13 18:06:23.000000000 +0000 +++ golang-github-containerd-typeurl-1.0.2/README.md 2021-03-18 03:27:13.000000000 +0000 @@ -1,8 +1,9 @@ # typeurl -[![Build Status](https://travis-ci.org/containerd/typeurl.svg?branch=master)](https://travis-ci.org/containerd/typeurl) - +[![PkgGoDev](https://pkg.go.dev/badge/github.com/containerd/typeurl)](https://pkg.go.dev/github.com/containerd/typeurl) +[![Build Status](https://github.com/containerd/typeurl/workflows/CI/badge.svg)](https://github.com/containerd/typeurl/actions?query=workflow%3ACI) [![codecov](https://codecov.io/gh/containerd/typeurl/branch/master/graph/badge.svg)](https://codecov.io/gh/containerd/typeurl) +[![Go Report Card](https://goreportcard.com/badge/github.com/containerd/typeurl)](https://goreportcard.com/report/github.com/containerd/typeurl) A Go package for managing the registration, marshaling, and unmarshaling of encoded types. diff -Nru golang-github-containerd-typeurl-1.0.1/types.go golang-github-containerd-typeurl-1.0.2/types.go --- golang-github-containerd-typeurl-1.0.1/types.go 2020-04-13 18:06:23.000000000 +0000 +++ golang-github-containerd-typeurl-1.0.2/types.go 2021-03-18 03:27:13.000000000 +0000 @@ -28,11 +28,20 @@ ) var ( - mu sync.Mutex + mu sync.RWMutex registry = make(map[reflect.Type]string) ) -var ErrNotFound = errors.New("not found") +// Definitions of common error types used throughout typeurl. +// +// These error types are used with errors.Wrap and errors.Wrapf to add context +// to an error. +// +// To detect an error class, use errors.Is() functions to tell whether an +// error is of this type. +var ( + ErrNotFound = errors.New("not found") +) // Register a type with a base URL for JSON marshaling. When the MarshalAny and // UnmarshalAny functions are called they will treat the Any type value as JSON. @@ -56,9 +65,9 @@ // TypeURL returns the type url for a registered type. func TypeURL(v interface{}) (string, error) { - mu.Lock() + mu.RLock() u, ok := registry[tryDereference(v)] - mu.Unlock() + mu.RUnlock() if !ok { // fallback to the proto registry if it is a proto message pb, ok := v.(proto.Message) @@ -119,14 +128,21 @@ return UnmarshalByTypeURL(any.TypeUrl, any.Value) } +// UnmarshalByTypeURL unmarshals the given type and value to into a concrete type. func UnmarshalByTypeURL(typeURL string, value []byte) (interface{}, error) { return unmarshal(typeURL, value, nil) } +// UnmarshalTo unmarshals the any type into a concrete type passed in the out +// argument. It is identical to UnmarshalAny, but lets clients provide a +// destination type through the out argument. func UnmarshalTo(any *types.Any, out interface{}) error { return UnmarshalToByTypeURL(any.TypeUrl, any.Value, out) } +// UnmarshalTo unmarshals the given type and value into a concrete type passed +// in the out argument. It is identical to UnmarshalByTypeURL, but lets clients +// provide a destination type through the out argument. func UnmarshalToByTypeURL(typeURL string, value []byte, out interface{}) error { _, err := unmarshal(typeURL, value, out) return err @@ -166,13 +182,16 @@ } func getTypeByUrl(url string) (urlType, error) { + mu.RLock() for t, u := range registry { if u == url { + mu.RUnlock() return urlType{ t: t, }, nil } } + mu.RUnlock() // fallback to proto registry t := proto.MessageType(url) if t != nil {