-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add command to generate empty/nil UUID (#10)
- Loading branch information
Showing
3 changed files
with
35 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package cmd | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/spf13/cobra" | ||
) | ||
|
||
// empty represents command generating empty UUID. | ||
var empty = &cobra.Command{ | ||
Use: "empty", | ||
Aliases: []string{"nil"}, | ||
Short: "Generate empty uuid", | ||
Long: `Generate empty: | ||
Generates empty (all-zeroes) uuid | ||
`, | ||
Run: func(cmd *cobra.Command, args []string) { | ||
const emptyUUID = "00000000-0000-0000-0000-000000000000" | ||
|
||
fmt.Println(emptyUUID) | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package main | ||
|
||
import "os" | ||
|
||
func ExampleGenerateEmpty() { | ||
// Pass argument to test 'uuid empty' command. | ||
os.Args = append(os.Args, "empty") | ||
|
||
main() | ||
// Output: 00000000-0000-0000-0000-000000000000 | ||
} |