Skip to content

Commit

Permalink
chore: updates for Go 1.22 (#2440)
Browse files Browse the repository at this point in the history
  • Loading branch information
codyoss committed Feb 27, 2024
1 parent d290e18 commit 82eaa79
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 60 deletions.
76 changes: 38 additions & 38 deletions doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
46 changes: 24 additions & 22 deletions internal/kokoro/vet.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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)
3 changes: 3 additions & 0 deletions internal/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
}
Expand Down

0 comments on commit 82eaa79

Please sign in to comment.