go.mod: Use the new "tool" directive

Previously the Go toolchain had no explicit support for "tools" and so we
used the typical Go community workaround of adding "tools.go" files (two,
for some reason) that existed only to trick the Go toolchain into
considering the tools as dependencies we could track in go.mod.

Go 1.24 introduced explicit support for tracking tools as part of go.mod,
and the ability to run those using "go tool" instead of "go run", and so
this commit switches us over to using that strategy for everything we were
previously managing in tools.go.

There are some intentional exceptions here:

- The protobuf-compile script can't use "go tool" or "go run" because the
  tools in question are run only indirectly through protoc. However, we
  do still use the "tool" directive in go.mod to tell the Go toolchain that
  we depend on those tools, so that it'll track which versions we are
  currently using as part of go.mod.
- Our golangci-lint Makefile target uses "go run" to run a specific
  version of golangci-lint. We _intentionally_ don't consider that tool
  to be a direct dependency of OpenTofu because it has a lot of indirect
  dependencies that would pollute our go.mod file. Therefore that continues
  to use "go run" after this commit.
- Both of our tools.go files previously referred to
  github.com/nishanths/exhaustive , but nothing actually appears to be
  using that tool in the current OpenTofu tree, so it's no longer a
  dependency after this commit.

All of the dependencies we have _only_ for tools are now classified as
"indirect" in the go.mod file. This is the default behavior of the Go
toolchain and appears to be motivated by making it clearer that these
modules do not contribute anything to the runtime behavior of OpenTofu.
This also corrected a historical oddity in our go.mod where for some reason
the "indirect" dependencies had been split across two different "require"
directives; they are now all grouped together in a single directive.

Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
This commit is contained in:
Martin Atkins
2025-10-09 11:01:32 -07:00
committed by Diógenes Fernandes
parent c923b80089
commit e74bf2d0a1
38 changed files with 62 additions and 100 deletions

View File

@@ -175,7 +175,7 @@ jobs:
- name: "Copyright headers"
run: |
go run github.com/hashicorp/copywrite headers --plan
go tool github.com/hashicorp/copywrite headers --plan
if [[ $? != 0 ]]; then
echo >&2 "ERROR: some files are missing required copyright headers. Run `scripts/add-copyright-headers.sh` locally and then commit the updated files."
exit 1

48
go.mod
View File

@@ -1,5 +1,7 @@
module github.com/opentofu/opentofu
go 1.25.2
// At the time of adding this configuration, the new Go feature introduced here https://github.com/golang/go/issues/67061,
// was having a good amount of issues linked to, affecting AWS Firewall, GCP various services and a lot more.
// In go1.23 the godebug flag for this was named 'tlskyber', renamed in go1.24 to 'tlsmlkem'. https://tip.golang.org/doc/godebug#go-124
@@ -44,7 +46,6 @@ require (
github.com/hashicorp/aws-sdk-go-base/v2 v2.0.0-beta.65
github.com/hashicorp/consul/api v1.13.0
github.com/hashicorp/consul/sdk v0.8.0
github.com/hashicorp/copywrite v0.16.3
github.com/hashicorp/errwrap v1.1.0
github.com/hashicorp/go-cleanhttp v0.5.2
github.com/hashicorp/go-getter v1.8.2
@@ -70,9 +71,7 @@ require (
github.com/mitchellh/go-homedir v1.1.0
github.com/mitchellh/go-linereader v0.0.0-20190213213312-1b945b3263eb
github.com/mitchellh/go-wordwrap v1.0.1
github.com/mitchellh/gox v1.0.1
github.com/mitchellh/reflectwalk v1.0.2
github.com/nishanths/exhaustive v0.7.11
github.com/openbao/openbao/api/v2 v2.3.0
github.com/opencontainers/go-digest v1.0.0
github.com/opencontainers/image-spec v1.1.1
@@ -105,12 +104,9 @@ require (
golang.org/x/sys v0.37.0
golang.org/x/term v0.36.0
golang.org/x/text v0.28.0
golang.org/x/tools v0.35.0
google.golang.org/api v0.155.0
google.golang.org/grpc v1.76.0
google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.3.0
google.golang.org/protobuf v1.36.10
honnef.co/go/tools v0.4.2
k8s.io/api v0.23.4
k8s.io/apimachinery v0.23.4
k8s.io/client-go v0.23.4
@@ -118,35 +114,26 @@ require (
oras.land/oras-go/v2 v2.6.0
)
require (
github.com/Azure/azure-sdk-for-go/sdk/internal v1.11.2 // indirect
github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/internal v1.2.0 // indirect
github.com/Azure/go-autorest/autorest v0.11.24 // indirect
github.com/AzureAD/microsoft-authentication-library-for-go v1.4.2 // indirect
github.com/golang-jwt/jwt/v5 v5.2.2 // indirect
github.com/kylelemons/godebug v1.1.0 // indirect
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect
github.com/rogpeppe/go-internal v1.14.1 // indirect
github.com/stretchr/objx v0.5.2 // indirect
golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect
)
require (
cloud.google.com/go v0.112.0 // indirect
cloud.google.com/go/compute/metadata v0.7.0 // indirect
cloud.google.com/go/iam v1.1.5 // indirect
github.com/AlecAivazis/survey/v2 v2.3.6 // indirect
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.10.1
github.com/Azure/azure-sdk-for-go/sdk/internal v1.11.2 // indirect
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources v1.2.0
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/storage/armstorage v1.8.0
github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/azkeys v1.4.0
github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/internal v1.2.0 // indirect
github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.6.1
github.com/Azure/go-autorest v14.2.0+incompatible // indirect
github.com/Azure/go-autorest/autorest v0.11.24 // indirect
github.com/Azure/go-autorest/autorest/adal v0.9.18 // indirect
github.com/Azure/go-autorest/autorest/date v0.3.0 // indirect
github.com/Azure/go-autorest/logger v0.2.1 // indirect
github.com/Azure/go-autorest/tracing v0.6.0 // indirect
github.com/Azure/go-ntlmssp v0.0.0-20200615164410-66371956d46c // indirect
github.com/AzureAD/microsoft-authentication-library-for-go v1.4.2 // indirect
github.com/BurntSushi/toml v1.2.1 // indirect
github.com/ChrisTrenkamp/goxpath v0.0.0-20190607011252-c5096ec8773d // indirect
github.com/Masterminds/goutils v1.1.1 // indirect
@@ -196,6 +183,7 @@ require (
github.com/gofrs/uuid v4.0.0+incompatible // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang-jwt/jwt/v4 v4.5.2 // indirect
github.com/golang-jwt/jwt/v5 v5.2.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/go-github/v45 v45.2.0 // indirect
@@ -205,6 +193,7 @@ require (
github.com/googleapis/enterprise-certificate-proxy v0.3.2 // indirect
github.com/googleapis/gnostic v0.5.5 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.0 // indirect
github.com/hashicorp/copywrite v0.16.3 // indirect
github.com/hashicorp/go-immutable-radix v1.0.0 // indirect
github.com/hashicorp/go-msgpack v0.5.4 // indirect
github.com/hashicorp/go-rootcerts v1.0.2 // indirect
@@ -227,6 +216,7 @@ require (
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect
github.com/klauspost/compress v1.15.11 // indirect
github.com/knadh/koanf v1.5.0 // indirect
github.com/kylelemons/godebug v1.1.0 // indirect
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
github.com/masterzen/simplexml v0.0.0-20190410153822-31eea3082786 // indirect
github.com/mattn/go-colorable v0.1.14 // indirect
@@ -234,6 +224,7 @@ require (
github.com/mergestat/timediff v0.0.3 // indirect
github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d // indirect
github.com/mitchellh/go-testing-interface v1.14.1 // indirect
github.com/mitchellh/gox v1.0.1 // indirect
github.com/mitchellh/iochan v1.0.0 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
@@ -243,13 +234,16 @@ require (
github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d // indirect
github.com/oklog/run v1.1.0 // indirect
github.com/oklog/ulid v1.3.1 // indirect
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect
github.com/rivo/uniseg v0.2.0 // indirect
github.com/rogpeppe/go-internal v1.14.1 // indirect
github.com/ryanuber/go-glob v1.0.0 // indirect
github.com/samber/lo v1.37.0 // indirect
github.com/shopspring/decimal v1.3.1 // indirect
github.com/spf13/cast v1.5.0 // indirect
github.com/spf13/cobra v1.6.1 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/stretchr/objx v0.5.2 // indirect
github.com/thanhpk/randstr v1.0.4 // indirect
github.com/thlib/go-timezone-local v0.0.0-20210907160436-ef149e42d28e // indirect
github.com/ulikunitz/xz v0.5.15 // indirect
@@ -265,16 +259,20 @@ require (
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.21.0 // indirect
go.opentelemetry.io/otel/metric v1.38.0 // indirect
go.opentelemetry.io/proto/otlp v1.0.0 // indirect
golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect
golang.org/x/exp/typeparams v0.0.0-20221208152030-732eee02a75a // indirect
golang.org/x/time v0.11.0 // indirect
golang.org/x/tools v0.35.0 // indirect
golang.org/x/tools/go/expect v0.1.1-deprecated // indirect
google.golang.org/genproto v0.0.0-20240123012728-ef4313101c80 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20250804133106-a7a43d27e69b // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b // indirect
google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.3.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/ini.v1 v1.66.2 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
honnef.co/go/tools v0.4.2 // indirect
k8s.io/klog/v2 v2.30.0 // indirect
k8s.io/kube-openapi v0.0.0-20211115234752-e816edb12b65 // indirect
sigs.k8s.io/json v0.0.0-20211020170558-c049b76a60c6 // indirect
@@ -282,6 +280,14 @@ require (
sigs.k8s.io/yaml v1.2.0 // indirect
)
go 1.25.2
replace github.com/hashicorp/hcl/v2 v2.20.1 => github.com/opentofu/hcl/v2 v2.20.2-0.20250121132637-504036cd70e7
tool (
github.com/hashicorp/copywrite
github.com/mitchellh/gox
go.uber.org/mock/mockgen
golang.org/x/tools/cmd/stringer
google.golang.org/grpc/cmd/protoc-gen-go-grpc
google.golang.org/protobuf/cmd/protoc-gen-go
honnef.co/go/tools/cmd/staticcheck
)

6
go.sum
View File

@@ -726,8 +726,6 @@ github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRW
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f/go.mod h1:ZdcZmHo+o7JKHSa8/e818NopupXU1YMK5fe1lsApnBw=
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
github.com/nishanths/exhaustive v0.7.11 h1:xV/WU3Vdwh5BUH4N06JNUznb6d5zhRPOnlgCrpNYNKA=
github.com/nishanths/exhaustive v0.7.11/go.mod h1:gX+MP7DWMKJmNa1HfMozK+u04hQd3na9i0hyqf3/dOI=
github.com/npillmayer/nestext v0.1.3/go.mod h1:h2lrijH8jpicr25dFY+oAJLyzlya6jhnuG+zWp9L0Uk=
github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d h1:VhgPp6v9qf9Agr/56bj7Y/xa04UccTW04VP0Qed4vnQ=
github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d/go.mod h1:YUTz3bUH2ZwIWBy3CJBeOBEugqcmXREj14T+iG/4k4U=
@@ -890,7 +888,6 @@ github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9de
github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
github.com/yuin/goldmark v1.4.0/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
github.com/zclconf/go-cty v1.17.0 h1:seZvECve6XX4tmnvRzWtJNHdscMtYEx5R7bnnVyd/d0=
github.com/zclconf/go-cty v1.17.0/go.mod h1:wqFzcImaLTI6A5HfsRwB0nj5n0MRZFwmey8YoFPPs3U=
@@ -1058,7 +1055,6 @@ golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v
golang.org/x/net v0.0.0-20210316092652-d523dce5a7f4/go.mod h1:RBQZq4jEuRlivfhVLdyRGr576XBO4/greRjx4P4O3yc=
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
golang.org/x/net v0.0.0-20210410081132-afb366fc7cd1/go.mod h1:9tjilg8BloeKEkVJvy7fQ90B1CfIiPueXVOjqfkSzI8=
golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.0.0-20211209124913-491a49abca63/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
@@ -1166,7 +1162,6 @@ golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210831042530-f4d43177bf5e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220209214540-3681064d5158/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
@@ -1274,7 +1269,6 @@ golang.org/x/tools v0.0.0-20210108195828-e2f9c7f1fc8e/go.mod h1:emZCQorbCU4vsT4f
golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0=
golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/tools v0.1.7/go.mod h1:LGqMHiF4EqQNHR1JncWGqT5BVaXmza+X+BDGol+dOxo=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
golang.org/x/tools v0.35.0 h1:mBffYraMEf7aa0sB+NuKnuCy8qI/9Bughn8dC2Gu5r0=

View File

@@ -84,7 +84,7 @@ func (k checkRuleKey) uniqueKeySigil() {}
// itself.)
type CheckRuleType int
//go:generate go run golang.org/x/tools/cmd/stringer -type=CheckRuleType check_rule.go
//go:generate go tool golang.org/x/tools/cmd/stringer -type=CheckRuleType check_rule.go
const (
InvalidCondition CheckRuleType = 0

View File

@@ -51,7 +51,7 @@ var (
// CheckableKind describes the different kinds of checkable objects.
type CheckableKind rune
//go:generate go run golang.org/x/tools/cmd/stringer -type=CheckableKind checkable.go
//go:generate go tool golang.org/x/tools/cmd/stringer -type=CheckableKind checkable.go
const (
CheckableKindInvalid CheckableKind = 0

View File

@@ -11,7 +11,7 @@ import "fmt"
// address can refer to.
type MoveEndpointKind rune
//go:generate go run golang.org/x/tools/cmd/stringer -type MoveEndpointKind
//go:generate go tool golang.org/x/tools/cmd/stringer -type MoveEndpointKind
const (
// MoveEndpointModule indicates that a move endpoint either refers to

View File

@@ -499,7 +499,7 @@ func (k configResourceKey) uniqueKeySigil() {}
// resource lifecycle has a slightly different address format.
type ResourceMode rune
//go:generate go run golang.org/x/tools/cmd/stringer -type ResourceMode
//go:generate go tool golang.org/x/tools/cmd/stringer -type ResourceMode
const (
// InvalidResourceMode is the zero value of ResourceMode and is not

View File

@@ -5,7 +5,7 @@
package backend
//go:generate go run golang.org/x/tools/cmd/stringer -type=OperationType operation_type.go
//go:generate go tool golang.org/x/tools/cmd/stringer -type=OperationType operation_type.go
// OperationType is an enum used with Operation to specify the operation
// type to perform for OpenTofu.

View File

@@ -5,7 +5,7 @@
package http
//go:generate go run go.uber.org/mock/mockgen -package $GOPACKAGE -source $GOFILE -destination mock_$GOFILE
//go:generate go tool go.uber.org/mock/mockgen -package $GOPACKAGE -source $GOFILE -destination mock_$GOFILE
import (
"context"

View File

@@ -15,7 +15,7 @@ import (
// checkable object.
type Status rune
//go:generate go run golang.org/x/tools/cmd/stringer -type=Status
//go:generate go tool golang.org/x/tools/cmd/stringer -type=Status
const (
// StatusUnknown represents that there is not yet a conclusive result

View File

@@ -19,7 +19,7 @@ import (
// the context of Cloud integration mode.
type ConfigChangeMode rune
//go:generate go run golang.org/x/tools/cmd/stringer -type ConfigChangeMode
//go:generate go tool golang.org/x/tools/cmd/stringer -type ConfigChangeMode
const (
// ConfigMigrationIn represents when the configuration calls for using

View File

@@ -32,7 +32,7 @@ type Show struct {
// shown by the "tofu show" command.
type ShowTargetType int
//go:generate go run golang.org/x/tools/cmd/stringer -type=ShowTargetType
//go:generate go tool golang.org/x/tools/cmd/stringer -type=ShowTargetType
const (
// ShowUnknownType is the zero value of [ShowTargetType], and represents
// that the target type is ambiguous and so must be inferred by the

View File

@@ -146,7 +146,7 @@ type NestingMode int
// Object represents the embedding of a NestedBl
//go:generate go run golang.org/x/tools/cmd/stringer -type=NestingMode
//go:generate go tool golang.org/x/tools/cmd/stringer -type=NestingMode
const (
nestingModeInvalid NestingMode = iota

View File

@@ -208,7 +208,7 @@ type Connection struct {
// ProvisionerWhen is an enum for valid values for when to run provisioners.
type ProvisionerWhen int
//go:generate go run golang.org/x/tools/cmd/stringer -type ProvisionerWhen
//go:generate go tool golang.org/x/tools/cmd/stringer -type ProvisionerWhen
const (
ProvisionerWhenInvalid ProvisionerWhen = iota
@@ -220,7 +220,7 @@ const (
// for provisioners.
type ProvisionerOnFailure int
//go:generate go run golang.org/x/tools/cmd/stringer -type ProvisionerOnFailure
//go:generate go tool golang.org/x/tools/cmd/stringer -type ProvisionerOnFailure
const (
ProvisionerOnFailureInvalid ProvisionerOnFailure = iota

View File

@@ -24,7 +24,7 @@ package configs
// - TypeHintMap requires a type that could be converted to an object
type VariableTypeHint rune
//go:generate go run golang.org/x/tools/cmd/stringer -type VariableTypeHint
//go:generate go tool golang.org/x/tools/cmd/stringer -type VariableTypeHint
// TypeHintNone indicates the absence of a type hint. Values specified in
// ambiguous contexts will be treated as literal strings, as if TypeHintString

View File

@@ -5,7 +5,7 @@
package schema
//go:generate go run golang.org/x/tools/cmd/stringer -type=getSource resource_data_get_source.go
//go:generate go tool golang.org/x/tools/cmd/stringer -type=getSource resource_data_get_source.go
// getSource represents the level we want to get for a value (internally).
// Any source less than or equal to the level will be loaded (whichever

View File

@@ -5,7 +5,7 @@
package schema
//go:generate go run golang.org/x/tools/cmd/stringer -type=ValueType valuetype.go
//go:generate go tool golang.org/x/tools/cmd/stringer -type=ValueType valuetype.go
// ValueType is an enum of the type that can be represented by a schema.
type ValueType int

View File

@@ -5,7 +5,7 @@
package tofu
//go:generate go run golang.org/x/tools/cmd/stringer -type=InstanceType instancetype.go
//go:generate go tool golang.org/x/tools/cmd/stringer -type=InstanceType instancetype.go
// InstanceType is an enum of the various types of instances store in the State
type InstanceType int

View File

@@ -5,7 +5,7 @@
package tofu
//go:generate go run golang.org/x/tools/cmd/stringer -type=ResourceMode -output=resource_mode_string.go resource_mode.go
//go:generate go tool golang.org/x/tools/cmd/stringer -type=ResourceMode -output=resource_mode_string.go resource_mode.go
// ResourceMode is deprecated, use addrs.ResourceMode instead.
// It has been preserved for backwards compatibility.

View File

@@ -15,7 +15,7 @@ package moduletest
//
// See the Status.Merge function for this requirement being used in action.
//
//go:generate go run golang.org/x/tools/cmd/stringer -type=Status status.go
//go:generate go tool golang.org/x/tools/cmd/stringer -type=Status status.go
type Status int
const (

View File

@@ -22,7 +22,7 @@ const (
// Instead, we have hooks for those to show progress.
)
//go:generate go run golang.org/x/tools/cmd/stringer -type Action
//go:generate go tool golang.org/x/tools/cmd/stringer -type Action
// IsReplace returns true if the action is one of the two actions that
// represents replacing an existing object with a new object:

View File

@@ -394,7 +394,7 @@ func (rc *ResourceInstanceChange) Simplify(destroying bool) *ResourceInstanceCha
// apply step.
type ResourceInstanceChangeActionReason rune
//go:generate go run golang.org/x/tools/cmd/stringer -type=ResourceInstanceChangeActionReason changes.go
//go:generate go tool golang.org/x/tools/cmd/stringer -type=ResourceInstanceChangeActionReason changes.go
const (
// In most cases there's no special reason for choosing a particular

View File

@@ -8,7 +8,7 @@ package plans
// Mode represents the various mutually-exclusive modes for creating a plan.
type Mode rune
//go:generate go run golang.org/x/tools/cmd/stringer -type Mode
//go:generate go tool golang.org/x/tools/cmd/stringer -type Mode
const (
// NormalMode is the default planning mode, which aims to synchronize the

View File

@@ -10,7 +10,7 @@ package plans
// have multiple qualities.
type Quality int
//go:generate go run golang.org/x/tools/cmd/stringer -type Quality
//go:generate go tool golang.org/x/tools/cmd/stringer -type Quality
const (
// Errored plans did not successfully complete, and cannot be applied.

View File

@@ -3,6 +3,6 @@
// Copyright (c) 2023 HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
//go:generate go run go.uber.org/mock/mockgen -destination mock.go github.com/opentofu/opentofu/internal/tfplugin5 ProviderClient,ProvisionerClient,Provisioner_ProvisionResourceClient,Provisioner_ProvisionResourceServer
//go:generate go tool go.uber.org/mock/mockgen -destination mock.go github.com/opentofu/opentofu/internal/tfplugin5 ProviderClient,ProvisionerClient,Provisioner_ProvisionResourceClient,Provisioner_ProvisionResourceServer
package mock_tfplugin5

View File

@@ -3,6 +3,6 @@
// Copyright (c) 2023 HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
//go:generate go run go.uber.org/mock/mockgen -destination mock.go github.com/opentofu/opentofu/internal/tfplugin6 ProviderClient
//go:generate go tool go.uber.org/mock/mockgen -destination mock.go github.com/opentofu/opentofu/internal/tfplugin6 ProviderClient
package mock_tfplugin6

View File

@@ -14,7 +14,7 @@ import (
// the currently-available context.
type DeferralReason int
//go:generate go run golang.org/x/tools/cmd/stringer -type=DeferralReason
//go:generate go tool golang.org/x/tools/cmd/stringer -type=DeferralReason
const (
// DeferredReasonUnknown is the zero value of DeferralReason, used when

View File

@@ -55,7 +55,7 @@ type ResourceInstanceObject struct {
// ObjectStatus represents the status of a RemoteObject.
type ObjectStatus rune
//go:generate go run golang.org/x/tools/cmd/stringer -type ObjectStatus
//go:generate go tool golang.org/x/tools/cmd/stringer -type ObjectStatus
const (
// ObjectReady is an object status for an object that is ready to use.

View File

@@ -134,7 +134,7 @@ func Export(mgr Reader) *statefile.File {
// is the receiver of that method and the "second" is the given argument.
type SnapshotMetaRel rune
//go:generate go run golang.org/x/tools/cmd/stringer -type=SnapshotMetaRel
//go:generate go tool golang.org/x/tools/cmd/stringer -type=SnapshotMetaRel
const (
// SnapshotOlder indicates that two snapshots have a common lineage and

View File

@@ -31,7 +31,7 @@ type Diagnostic interface {
type Severity rune
//go:generate go run golang.org/x/tools/cmd/stringer -type=Severity
//go:generate go tool golang.org/x/tools/cmd/stringer -type=Severity
const (
Error Severity = 'E'

View File

@@ -5,7 +5,7 @@
package tofu
//go:generate go run golang.org/x/tools/cmd/stringer -type=DeprecationWarningLevel deprecation_level.go
//go:generate go tool golang.org/x/tools/cmd/stringer -type=DeprecationWarningLevel deprecation_level.go
import (
"log"

View File

@@ -5,7 +5,7 @@
package tofu
//go:generate go run golang.org/x/tools/cmd/stringer -type=walkOperation graph_walk_operation.go
//go:generate go tool golang.org/x/tools/cmd/stringer -type=walkOperation graph_walk_operation.go
// walkOperation is an enum which tells the walkContext what to do.
type walkOperation byte

View File

@@ -474,7 +474,7 @@ const (
prevRunState
)
//go:generate go run golang.org/x/tools/cmd/stringer -type phaseState
//go:generate go tool golang.org/x/tools/cmd/stringer -type phaseState
// writeResourceInstanceState saves the given object as the current object for
// the selected resource instance.

View File

@@ -139,7 +139,7 @@ func (v ValueSourceType) GoString() string {
return fmt.Sprintf("tofu.%s", v)
}
//go:generate go run golang.org/x/tools/cmd/stringer -type ValueSourceType
//go:generate go tool golang.org/x/tools/cmd/stringer -type ValueSourceType
// InputValues is a map of InputValue instances.
type InputValues map[string]*InputValue

View File

@@ -4,4 +4,4 @@
# Copyright (c) 2023 HashiCorp, Inc.
# SPDX-License-Identifier: MPL-2.0
go run github.com/hashicorp/copywrite headers
go tool github.com/hashicorp/copywrite headers

View File

@@ -20,4 +20,4 @@ packages=$(go list ./... | egrep -v ${skip})
# may result in bugs. We also disable function deprecation checks (SA1019)
# because our policy is to update deprecated calls locally while making other
# nearby changes, rather than to make cross-cutting changes to update them all.
go run honnef.co/go/tools/cmd/staticcheck -checks 'all,-SA1019,-ST*' ${packages}
go tool honnef.co/go/tools/cmd/staticcheck -checks 'all,-SA1019,-ST*' ${packages}

View File

@@ -1,20 +0,0 @@
// Copyright (c) The OpenTofu Authors
// SPDX-License-Identifier: MPL-2.0
// Copyright (c) 2023 HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
//go:build tools
// +build tools
package tools
// This file tracks some external tools we use during development and release
// processes. These are not used at runtime but having them here allows the
// Go toolchain to see that we need to include them in go.mod and go.sum.
import (
_ "github.com/hashicorp/copywrite"
_ "github.com/nishanths/exhaustive/cmd/exhaustive"
_ "golang.org/x/tools/cmd/stringer"
_ "honnef.co/go/tools/cmd/staticcheck"
)

View File

@@ -1,18 +0,0 @@
// Copyright (c) The OpenTofu Authors
// SPDX-License-Identifier: MPL-2.0
// Copyright (c) 2023 HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
//go:build tools
// +build tools
package tools
import (
_ "github.com/mitchellh/gox"
_ "github.com/nishanths/exhaustive"
_ "go.uber.org/mock/mockgen"
_ "golang.org/x/tools/cmd/stringer"
_ "google.golang.org/grpc/cmd/protoc-gen-go-grpc"
_ "honnef.co/go/tools/cmd/staticcheck"
)