Skip to content

Commit fbc3412

Browse files
committed
deps: Remove golang.org/x/exp dependency
Reference: golang/go#61914 It was only used for the `constraints` package, the type definitions are relatively trivial and static, and the Go language maintainers are not sure if/where these will live in the standard library, which implies (at least to me) they could also disappear from x/exp.
1 parent a4dd140 commit fbc3412

File tree

4 files changed

+29
-7
lines changed

4 files changed

+29
-7
lines changed

config/constraints.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Copyright (c) HashiCorp, Inc.
2+
// SPDX-License-Identifier: MPL-2.0
3+
4+
package config
5+
6+
// anyFloat is a constraint that permits any floating-point type. This type
7+
// definition is copied rather than depending on x/exp/constraints since the
8+
// dependency is otherwise unneeded, the definition is relatively trivial and
9+
// static, and the Go language maintainers are not sure if/where these will live
10+
// in the standard library.
11+
//
12+
// Reference: https://github.com/golang/go/issues/61914
13+
type anyFloat interface {
14+
~float32 | ~float64
15+
}
16+
17+
// anyInteger is a constraint that permits any integer type. This type
18+
// definition is copied rather than depending on x/exp/constraints since the
19+
// dependency is otherwise unneeded, the definition is relatively trivial and
20+
// static, and the Go language maintainers are not sure if/where these will live
21+
// in the standard library.
22+
//
23+
// Reference: https://github.com/golang/go/issues/61914
24+
type anyInteger interface {
25+
~int | ~int8 | ~int16 | ~int32 | ~int64 |
26+
~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uintptr
27+
}

config/variable.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ import (
1010
"os"
1111
"path/filepath"
1212
"reflect"
13-
14-
"golang.org/x/exp/constraints"
1513
)
1614

1715
const autoTFVarsJson = "terraform-plugin-testing.auto.tfvars.json"
@@ -81,7 +79,7 @@ func (v floatVariable) MarshalJSON() ([]byte, error) {
8179
}
8280

8381
// FloatVariable returns floatVariable which implements Variable.
84-
func FloatVariable[T constraints.Float](value T) floatVariable {
82+
func FloatVariable[T anyFloat](value T) floatVariable {
8583
return floatVariable{
8684
value: value,
8785
}
@@ -100,7 +98,7 @@ func (v integerVariable) MarshalJSON() ([]byte, error) {
10098
}
10199

102100
// IntegerVariable returns integerVariable which implements Variable.
103-
func IntegerVariable[T constraints.Integer](value T) integerVariable {
101+
func IntegerVariable[T anyInteger](value T) integerVariable {
104102
return integerVariable{
105103
value: value,
106104
}

go.mod

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ require (
2121
github.com/mitchellh/reflectwalk v1.0.2
2222
github.com/zclconf/go-cty v1.14.1
2323
golang.org/x/crypto v0.17.0
24-
golang.org/x/exp v0.0.0-20230809150735-7b3493d9a819
2524
)
2625

2726
require (

go.sum

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,6 @@ golang.org/x/crypto v0.3.1-0.20221117191849-2c476679df9a/go.mod h1:hebNnKkNXi2Uz
126126
golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU=
127127
golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k=
128128
golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4=
129-
golang.org/x/exp v0.0.0-20230809150735-7b3493d9a819 h1:EDuYyU/MkFXllv9QF9819VlI9a4tzGuCbhG0ExK9o1U=
130-
golang.org/x/exp v0.0.0-20230809150735-7b3493d9a819/go.mod h1:FXUEEKJgO7OQYeo8N01OfiKP8RXMtf6e8aTskBGqWdc=
131129
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
132130
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
133131
golang.org/x/mod v0.14.0 h1:dGoOF9QVLYng8IHTm7BAyWqCqSheQ5pYWGhzW00YJr0=

0 commit comments

Comments
 (0)