diff --git a/doc.go b/doc.go index 3095f42b1e..57e6f50e4a 100644 --- a/doc.go +++ b/doc.go @@ -93,42 +93,42 @@ // Operation.Done field indicates it is finished. To do this, use the service's // Operation client, and a loop, like so: // -// import ( -// gax "github.com/googleapis/gax-go/v2" -// ) -// -// // existing application code... -// -// // API call that returns an Operation. -// op, err := myApiClient.CalculateFoo().Do() -// if err != nil { -// // handle err -// } -// -// operationsService = myapi.NewOperationsService(myApiClient) -// pollingBackoff := gax.Backoff{ -// Initial: time.Second, -// Max: time.Minute, // Max time between polling attempts. -// Multiplier: 2, -// } -// for { -// if op.Done { -// break -// } -// // not done, sleep with backoff, then poll again -// if err := gax.Sleep(ctx, pollingBackoff.Pause()); err != nil { -// // handle error -// } -// op, err := operationsService.Get(op.Name).Do() -// if err != nil { -// // handle error -// } -// } -// -// if op.Error != nil { -// // handle operation err -// } -// -// // Do something with the response -// fmt.Println(op.Response) +// import ( +// gax "github.com/googleapis/gax-go/v2" +// ) +// +// // existing application code... +// +// // API call that returns an Operation. +// op, err := myApiClient.CalculateFoo().Do() +// if err != nil { +// // handle err +// } +// +// operationsService = myapi.NewOperationsService(myApiClient) +// pollingBackoff := gax.Backoff{ +// Initial: time.Second, +// Max: time.Minute, // Max time between polling attempts. +// Multiplier: 2, +// } +// for { +// if op.Done { +// break +// } +// // not done, sleep with backoff, then poll again +// if err := gax.Sleep(ctx, pollingBackoff.Pause()); err != nil { +// // handle error +// } +// op, err := operationsService.Get(op.Name).Do() +// if err != nil { +// // handle error +// } +// } +// +// if op.Error != nil { +// // handle operation err +// } +// +// // Do something with the response +// fmt.Println(op.Response) package api diff --git a/internal/kokoro/vet.sh b/internal/kokoro/vet.sh index 15b9f2e339..865eaa5ec9 100755 --- a/internal/kokoro/vet.sh +++ b/internal/kokoro/vet.sh @@ -7,7 +7,7 @@ # Fail on error, and display commands being run. set -ex -if [[ $(go version) != *"go1.20"* ]]; then +if [[ $(go version) != *"go1.22"* ]]; then exit 0 fi @@ -25,24 +25,26 @@ goimports -l . 2>&1 | tee /dev/stderr | (! read) # Runs the linter. Regrettably the linter is very simple and does not provide the ability to exclude rules or files, # so we rely on inverse grepping to do this for us. -golint ./... 2>&1 | ( \ - grep -v "gen.go" | \ - grep -v "disco.go" | \ - grep -v "exported const DefaultDelayThreshold should have comment" | \ - grep -v "exported const DefaultBundleCountThreshold should have comment" | \ - grep -v "exported const DefaultBundleByteThreshold should have comment" | \ - grep -v "exported const DefaultBufferedByteLimit should have comment" | \ - grep -v "error var Done should have name of the form ErrFoo" | \ - grep -v "exported method APIKey.RoundTrip should have comment or be unexported" | \ - grep -v "exported method MarshalStyle.JSONReader should have comment or be unexported" | \ - grep -v "UnmarshalJSON should have comment or be unexported" | \ - grep -v "MarshalJSON should have comment or be unexported" | \ - grep -v ".Apply should have comment or be unexported" | \ - grep -vE "\.pb\.go:" || true) | tee /dev/stderr | (! read) - -staticcheck -go 1.9 ./... 2>&1 | ( \ - grep -v "SA1019" | \ - grep -v "S1007" | \ - grep -v "error var Done should have name of the form ErrFoo" | \ - grep -v "examples" | \ - grep -v "gen.go" || true) | tee /dev/stderr | (! read) +golint ./... 2>&1 | ( + grep -v "gen.go" | + grep -v "disco.go" | + grep -v "exported const DefaultDelayThreshold should have comment" | + grep -v "exported const DefaultBundleCountThreshold should have comment" | + grep -v "exported const DefaultBundleByteThreshold should have comment" | + grep -v "exported const DefaultBufferedByteLimit should have comment" | + grep -v "error var Done should have name of the form ErrFoo" | + grep -v "exported method APIKey.RoundTrip should have comment or be unexported" | + grep -v "exported method MarshalStyle.JSONReader should have comment or be unexported" | + grep -v "UnmarshalJSON should have comment or be unexported" | + grep -v "MarshalJSON should have comment or be unexported" | + grep -v ".Apply should have comment or be unexported" | + grep -vE "\.pb\.go:" || true +) | tee /dev/stderr | (! read) + +staticcheck -go 1.9 ./... 2>&1 | ( + grep -v "SA1019" | + grep -v "S1007" | + grep -v "error var Done should have name of the form ErrFoo" | + grep -v "examples" | + grep -v "gen.go" || true +) | tee /dev/stderr | (! read) diff --git a/internal/settings.go b/internal/settings.go index e17141a6f5..6b709da707 100644 --- a/internal/settings.go +++ b/internal/settings.go @@ -89,6 +89,7 @@ func (ds *DialSettings) HasCustomAudience() bool { return len(ds.Audiences) > 0 } +// IsNewAuthLibraryEnabled returns true if the new auth library should be used. func (ds *DialSettings) IsNewAuthLibraryEnabled() bool { if ds.EnableNewAuthLibrary { return true @@ -185,6 +186,8 @@ func (ds *DialSettings) GetUniverseDomain() string { return ds.UniverseDomain } +// IsUniverseDomainGDU returns true if the universe domain is the default Google +// universe. func (ds *DialSettings) IsUniverseDomainGDU() bool { return ds.GetUniverseDomain() == ds.GetDefaultUniverseDomain() }