this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

gotime,uuid: add new things

+124
+3
go.mod
··· 19 19 ) 20 20 21 21 require ( 22 + github.com/google/uuid v1.3.0 22 23 github.com/hashicorp/go-retryablehttp v0.7.1 24 + github.com/ijt/go-anytime v1.9.2 23 25 github.com/mergestat/timediff v0.0.3 24 26 github.com/oklog/ulid/v2 v2.1.0 25 27 golang.org/x/exp v0.0.0-20221126150942-6ab00d035af9 ··· 29 31 github.com/ChannelMeter/iso8601duration v0.0.0-20150204201828-8da3af7a2a61 // indirect 30 32 github.com/gorilla/websocket v1.4.2 // indirect 31 33 github.com/hashicorp/go-cleanhttp v0.5.1 // indirect 34 + github.com/ijt/goparsify v0.0.0-20221203142333-3a5276334b8d // indirect 32 35 gopkg.in/yaml.v3 v3.0.0-20200605160147-a5ece683394c // indirect 33 36 )
+7
go.sum
··· 15 15 github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= 16 16 github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg= 17 17 github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= 18 + github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= 19 + github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= 18 20 github.com/gorilla/websocket v1.2.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= 19 21 github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc= 20 22 github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= ··· 24 26 github.com/hashicorp/go-hclog v0.9.2/go.mod h1:5CU+agLiy3J7N7QjHK5d05KxGsuXiQLrjA0H7acj2lQ= 25 27 github.com/hashicorp/go-retryablehttp v0.7.1 h1:sUiuQAnLlbvmExtFQs72iFW/HXeUn8Z1aJLQ4LJJbTQ= 26 28 github.com/hashicorp/go-retryablehttp v0.7.1/go.mod h1:vAew36LZh98gCBJNLH42IQ1ER/9wtLZZ8meHqQvEYWY= 29 + github.com/ijt/go-anytime v1.9.2 h1:DmYgVwUiFPNR+n6c1T5P070tlGATRZG4aYNJs6XDUfU= 30 + github.com/ijt/go-anytime v1.9.2/go.mod h1:egBT6FhVjNlXNHUN2wTPi6ILCNKXeeXFy04pWJjw/LI= 31 + github.com/ijt/goparsify v0.0.0-20221203142333-3a5276334b8d h1:LFOmpWrSbtolg0YqYC9hQjj5WSLtRGb6aZ3JAugLfgg= 32 + github.com/ijt/goparsify v0.0.0-20221203142333-3a5276334b8d/go.mod h1:112TOyA+aruNSUBlyBWlKBdLVYTdhjiO2CKD0j/URSU= 27 33 github.com/johnmccabe/go-bitbar v0.5.0 h1:z0upYP2j9MjR5xfTRPxN19mVcgE2pj3A9W0wtTQo40Y= 28 34 github.com/johnmccabe/go-bitbar v0.5.0/go.mod h1:d24hzbH0CJB6AjMIss0EmZxanbWLSghuSMTFygwvCkw= 29 35 github.com/jomei/notionapi v1.5.0 h1:ZDDAblvAXuYJCTpSvG42ClaHSoCcL4zmP1A/A3S0fhY= ··· 59 65 github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= 60 66 github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= 61 67 github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= 68 + github.com/tj/assert v0.0.0-20190920132354-ee03d75cd160 h1:NSWpaDaurcAJY7PkL8Xt0PhZE7qpvbZl5ljd8r6U0bI= 62 69 golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= 63 70 golang.org/x/exp v0.0.0-20221126150942-6ab00d035af9 h1:yZNXmy+j/JpX19vZkVktWqAo7Gny4PBWYYK3zskGpx4= 64 71 golang.org/x/exp v0.0.0-20221126150942-6ab00d035af9/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc=
+72
gotime/main.go
··· 1 + package main 2 + 3 + import ( 4 + "flag" 5 + "fmt" 6 + "io" 7 + "os" 8 + "time" 9 + 10 + "github.com/ijt/go-anytime" 11 + ) 12 + 13 + const ( 14 + formatUnixEpoch = "unix" 15 + formatRFC3339ishWithoutTimeZone = "2006-01-02 15:04:05" 16 + ) 17 + 18 + func main() { 19 + if err := realMain( 20 + os.Args, 21 + os.Stdout, 22 + ); err != nil { 23 + fmt.Fprintf(os.Stderr, "%s\n", err) 24 + os.Exit(1) 25 + } 26 + } 27 + 28 + func realMain(args []string, stdout io.Writer) error { 29 + exec := args[0] 30 + 31 + fs := flag.NewFlagSet(exec, flag.ExitOnError) 32 + flagFormat := fs.String("f", formatRFC3339ishWithoutTimeZone, "format") 33 + flagUTC := fs.Bool("u", true, "use UTC") 34 + flagNow := fs.String("n", "", "time to use as now") 35 + 36 + if err := fs.Parse(args[1:]); err != nil { 37 + return err 38 + } 39 + 40 + fsargs := fs.Args() 41 + 42 + now := time.Now() 43 + if *flagNow != "" { 44 + n, err := anytime.Parse(*flagNow, now) 45 + if err != nil { 46 + return fmt.Errorf("now: %w", err) 47 + } 48 + now = n 49 + } 50 + 51 + if len(fsargs) == 0 { 52 + fs.Usage() 53 + return fmt.Errorf("missing argument") 54 + } 55 + t, err := anytime.Parse(fsargs[0], now) 56 + if err != nil { 57 + return err 58 + } 59 + 60 + if *flagUTC { 61 + t = t.UTC() 62 + } 63 + 64 + switch *flagFormat { 65 + case formatUnixEpoch: 66 + fmt.Fprintf(stdout, "%d\n", t.Unix()) 67 + default: 68 + fmt.Fprintf(stdout, "%s\n", t.Format(*flagFormat)) 69 + } 70 + 71 + return nil 72 + }
+42
uuid/main.go
··· 1 + package main 2 + 3 + import ( 4 + "flag" 5 + "fmt" 6 + "io" 7 + "os" 8 + "strings" 9 + 10 + "github.com/google/uuid" 11 + ) 12 + 13 + func main() { 14 + if err := realMain(os.Args, os.Stdout); err != nil { 15 + fmt.Fprintf(os.Stderr, "%s\n", err) 16 + os.Exit(1) 17 + } 18 + } 19 + 20 + func realMain(args []string, w io.Writer) error { 21 + flags := flag.NewFlagSet(args[0], flag.ExitOnError) 22 + flagNoDash := flags.Bool("no-dash", false, "") 23 + 24 + err := flags.Parse(args[1:]) 25 + if err != nil { 26 + return err 27 + } 28 + 29 + v, err := uuid.NewRandom() 30 + if err != nil { 31 + return err 32 + } 33 + 34 + uuidstr := v.String() 35 + if *flagNoDash { 36 + uuidstr = strings.ReplaceAll(v.String(), "-", "") 37 + } 38 + 39 + fmt.Fprintln(w, uuidstr) 40 + 41 + return nil 42 + }