File tree Expand file tree Collapse file tree 4 files changed +29
-7
lines changed Expand file tree Collapse file tree 4 files changed +29
-7
lines changed Original file line number Diff line number Diff line change
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
+ }
Original file line number Diff line number Diff line change @@ -10,8 +10,6 @@ import (
10
10
"os"
11
11
"path/filepath"
12
12
"reflect"
13
-
14
- "golang.org/x/exp/constraints"
15
13
)
16
14
17
15
const autoTFVarsJson = "terraform-plugin-testing.auto.tfvars.json"
@@ -81,7 +79,7 @@ func (v floatVariable) MarshalJSON() ([]byte, error) {
81
79
}
82
80
83
81
// FloatVariable returns floatVariable which implements Variable.
84
- func FloatVariable [T constraints. Float ](value T ) floatVariable {
82
+ func FloatVariable [T anyFloat ](value T ) floatVariable {
85
83
return floatVariable {
86
84
value : value ,
87
85
}
@@ -100,7 +98,7 @@ func (v integerVariable) MarshalJSON() ([]byte, error) {
100
98
}
101
99
102
100
// IntegerVariable returns integerVariable which implements Variable.
103
- func IntegerVariable [T constraints. Integer ](value T ) integerVariable {
101
+ func IntegerVariable [T anyInteger ](value T ) integerVariable {
104
102
return integerVariable {
105
103
value : value ,
106
104
}
Original file line number Diff line number Diff line change @@ -21,7 +21,6 @@ require (
21
21
github.com/mitchellh/reflectwalk v1.0.2
22
22
github.com/zclconf/go-cty v1.14.1
23
23
golang.org/x/crypto v0.17.0
24
- golang.org/x/exp v0.0.0-20230809150735-7b3493d9a819
25
24
)
26
25
27
26
require (
Original file line number Diff line number Diff line change @@ -126,8 +126,6 @@ golang.org/x/crypto v0.3.1-0.20221117191849-2c476679df9a/go.mod h1:hebNnKkNXi2Uz
126
126
golang.org/x/crypto v0.7.0 /go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU =
127
127
golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k =
128
128
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 =
131
129
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 /go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4 =
132
130
golang.org/x/mod v0.8.0 /go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs =
133
131
golang.org/x/mod v0.14.0 h1:dGoOF9QVLYng8IHTm7BAyWqCqSheQ5pYWGhzW00YJr0 =
You can’t perform that action at this time.
0 commit comments