Skip to content

Commit

Permalink
Use uuid.Validate for cases where the UUID isn't used
Browse files Browse the repository at this point in the history
In google/uuid#141 a new `Validate` function
was added to the `uuid` package. This can be used when no UUID
struct is required, so can be used instead of `Parse`.

This takes #1087, but uses
`uuid.Validate` in one location.
  • Loading branch information
hslatman committed Dec 19, 2023
1 parent d55769a commit ac097ff
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions command/api/token/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,10 @@ func createAction(ctx *cli.Context) (err error) {
Bundle: clientCert.Certificate,
Audience: ctx.String("audience"),
}
if _, err := uuid.Parse(teamID); err == nil {
r.TeamID = teamID
} else {
if err := uuid.Validate(teamID); err != nil {
r.TeamSlug = teamID
} else {
r.TeamID = teamID
}
err = json.NewEncoder(b).Encode(r)
if err != nil {
Expand Down

0 comments on commit ac097ff

Please sign in to comment.