mirror of
https://github.com/protocolbuffers/protobuf-go.git
synced 2025-03-10 07:14:24 +00:00
internal/weakdeps: put APIv1 weak dependency behind a build constraint
By using a build constraint that is never satisfied, we can add a weak dependency on a module. If the module is part of a build, our go.mod enforces a minimum version on it, but we never add it to the build dependencies ourselves. This is the same trick used for tool dependencies: https://github.com/golang/go/wiki/Modules#how-can-i-track-tool-dependencies-for-a-module Dropped the TODO to remove the APIv1 dependency, since I think this removes any need to do so. Change-Id: I45b1a3f45535bcdc9abf34fb562d2869f1712bb6 Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/219499 Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
This commit is contained in:
parent
5ca8f849d3
commit
06e51b76b4
@ -1,14 +0,0 @@
|
||||
// Copyright 2020 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// Package depv1 exists to depend on github.com/golang/protobuf.
|
||||
//
|
||||
// We include this dependency to ensure that any program using
|
||||
// APIv2 also uses a sufficiently new version of APIv1. At some
|
||||
// point in the future when old versions of APIv1 are no longer
|
||||
// of concern, we may drop this dependency.
|
||||
package depv1
|
||||
|
||||
// TODO: Delete this dependency when it no longer serves a purpose.
|
||||
import _ "github.com/golang/protobuf/proto"
|
12
internal/weakdeps/doc.go
Normal file
12
internal/weakdeps/doc.go
Normal file
@ -0,0 +1,12 @@
|
||||
// Copyright 2020 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// Package weakdeps exists to add weak module dependencies.
|
||||
//
|
||||
// We want to ensure that this module is used with a minimum
|
||||
// version of certain other modules, without actually importing
|
||||
// those modules in normal builds. We do that by adding an
|
||||
// import of a package in the module under a build constraint
|
||||
// that is never satisfied in normal usage.
|
||||
package weakdeps
|
11
internal/weakdeps/weakdeps.go
Normal file
11
internal/weakdeps/weakdeps.go
Normal file
@ -0,0 +1,11 @@
|
||||
// Copyright 2020 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build weak_dependency
|
||||
|
||||
package weakdeps
|
||||
|
||||
// Ensure that any program using "github.com/golang/protobuf"
|
||||
// uses a version that wraps this module.
|
||||
import _ "github.com/golang/protobuf/proto"
|
Loading…
x
Reference in New Issue
Block a user