diff --git a/cmd/fitactivity/combiner/combiner.go b/cmd/fitactivity/combiner/combiner.go index e088a0a7..388f682f 100644 --- a/cmd/fitactivity/combiner/combiner.go +++ b/cmd/fitactivity/combiner/combiner.go @@ -8,6 +8,8 @@ import ( "fmt" "time" + "slices" + "github.com/muktihari/fit/cmd/fitactivity/aggregator" "github.com/muktihari/fit/factory" "github.com/muktihari/fit/kit/datetime" @@ -17,7 +19,6 @@ import ( "github.com/muktihari/fit/profile/untyped/fieldnum" "github.com/muktihari/fit/profile/untyped/mesgnum" "github.com/muktihari/fit/proto" - "golang.org/x/exp/slices" ) type errorString string diff --git a/cmd/fitactivity/combiner/combiner_test.go b/cmd/fitactivity/combiner/combiner_test.go index 4baec1a8..dc0c4cd1 100644 --- a/cmd/fitactivity/combiner/combiner_test.go +++ b/cmd/fitactivity/combiner/combiner_test.go @@ -10,6 +10,8 @@ import ( "testing" "time" + "slices" + "github.com/google/go-cmp/cmp" "github.com/muktihari/fit/factory" "github.com/muktihari/fit/kit/datetime" @@ -19,7 +21,6 @@ import ( "github.com/muktihari/fit/profile/untyped/fieldnum" "github.com/muktihari/fit/profile/untyped/mesgnum" "github.com/muktihari/fit/proto" - "golang.org/x/exp/slices" ) func TestCombine(t *testing.T) { diff --git a/go.mod b/go.mod index 543ccbfc..571fdceb 100644 --- a/go.mod +++ b/go.mod @@ -1,13 +1,12 @@ module github.com/muktihari/fit -go 1.20 +go 1.21 require ( github.com/client9/misspell v0.3.4 github.com/google/go-cmp v0.6.0 github.com/muktihari/carto v0.1.1 github.com/thedatashed/xlsxreader v1.2.8 - golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc golang.org/x/text v0.18.0 ) diff --git a/go.sum b/go.sum index bda533fc..3bd691e8 100644 --- a/go.sum +++ b/go.sum @@ -2,6 +2,7 @@ github.com/client9/misspell v0.3.4 h1:ta993UF76GwbvJcIo3Y68y/M3WxlpEHPWIGDkJYwzJ github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/muktihari/carto v0.1.1 h1:2onp1tC7uYLBQy5WuIJyP5A6oQq3duRkcO3kf6+hzR0= @@ -14,8 +15,7 @@ github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsT github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/thedatashed/xlsxreader v1.2.8 h1:8aGbkXIPEThQbA8KzUZqIa4v4oqFrJFKLQ36vWePI5U= github.com/thedatashed/xlsxreader v1.2.8/go.mod h1:wZyb/2xF1+rkZ2ujhC72tuuOWBY574QvcXHFls+5AXc= -golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc h1:O9NuF4s+E/PvMIy+9IUZB9znFwUIXEWSstNjek6VpVg= -golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc/go.mod h1:XtvwrStGgqGPLc4cjQfWqZHG1YFdYs6swckp8vpsjnc= golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224= golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/internal/cmd/benchfit/go.mod b/internal/cmd/benchfit/go.mod index d1da9d2d..08d68b37 100644 --- a/internal/cmd/benchfit/go.mod +++ b/internal/cmd/benchfit/go.mod @@ -1,6 +1,6 @@ module benchfit -go 1.20 +go 1.21 require ( github.com/muktihari/fit v0.0.0 diff --git a/internal/cmd/fitgen/pkg/flagutil/flagutil.go b/internal/cmd/fitgen/pkg/flagutil/flagutil.go index e127cb42..30980503 100644 --- a/internal/cmd/fitgen/pkg/flagutil/flagutil.go +++ b/internal/cmd/fitgen/pkg/flagutil/flagutil.go @@ -10,7 +10,7 @@ import ( "os" "strings" - "golang.org/x/exp/slices" + "slices" ) func Usage() { diff --git a/internal/cmd/fitgen/pkg/strutil/strutil_test.go b/internal/cmd/fitgen/pkg/strutil/strutil_test.go index 62d51ba9..2f4c9d55 100644 --- a/internal/cmd/fitgen/pkg/strutil/strutil_test.go +++ b/internal/cmd/fitgen/pkg/strutil/strutil_test.go @@ -5,11 +5,47 @@ package strutil_test import ( + "fmt" "testing" "github.com/muktihari/fit/internal/cmd/fitgen/pkg/strutil" ) +func BenchmarkToTitle(b *testing.B) { + for i := 0; i < b.N; i++ { + _ = strutil.ToTitle("avg_speed") + } +} + +func TestToTitle(t *testing.T) { + tt := []struct { + input string + output string + }{ + { + input: "avg_speed", + output: "AvgSpeed", + }, + { + input: "avg speed", + output: "AvgSpeed", + }, + { + input: "timestamp_32k", + output: "Timestamp32K", + }, + } + + for i, tc := range tt { + t.Run(fmt.Sprintf("[%d] %s", i, tc.input), func(t *testing.T) { + out := strutil.ToTitle(tc.input) + if out != tc.output { + t.Fatalf("expected: %q, got: %q", tc.output, out) + } + }) + } +} + func TestTrimRepeatedChar(t *testing.T) { tt := []struct { s string diff --git a/internal/cmd/fitgen/profile/mesgdef/builder.go b/internal/cmd/fitgen/profile/mesgdef/builder.go index 40eb50fa..e617f0f6 100644 --- a/internal/cmd/fitgen/profile/mesgdef/builder.go +++ b/internal/cmd/fitgen/profile/mesgdef/builder.go @@ -12,12 +12,13 @@ import ( "strings" "text/template" + "slices" + "github.com/muktihari/fit/internal/cmd/fitgen/generator" "github.com/muktihari/fit/internal/cmd/fitgen/lookup" "github.com/muktihari/fit/internal/cmd/fitgen/parser" "github.com/muktihari/fit/internal/cmd/fitgen/pkg/strutil" "github.com/muktihari/fit/profile/basetype" - "golang.org/x/exp/slices" ) type Builder struct { diff --git a/internal/cmd/fitgen/profile/untyped/fieldnum/builder.go b/internal/cmd/fitgen/profile/untyped/fieldnum/builder.go index b2064a94..0479050b 100644 --- a/internal/cmd/fitgen/profile/untyped/fieldnum/builder.go +++ b/internal/cmd/fitgen/profile/untyped/fieldnum/builder.go @@ -12,12 +12,13 @@ import ( "strings" "text/template" + "slices" + "github.com/muktihari/fit/internal/cmd/fitgen/generator" "github.com/muktihari/fit/internal/cmd/fitgen/lookup" "github.com/muktihari/fit/internal/cmd/fitgen/parser" "github.com/muktihari/fit/internal/cmd/fitgen/pkg/strutil" "github.com/muktihari/fit/internal/cmd/fitgen/shared" - "golang.org/x/exp/slices" ) type Builder struct { diff --git a/kit/scaleoffset/scaleoffset.go b/kit/scaleoffset/scaleoffset.go index f83bea17..227dea32 100644 --- a/kit/scaleoffset/scaleoffset.go +++ b/kit/scaleoffset/scaleoffset.go @@ -7,11 +7,10 @@ package scaleoffset import ( "github.com/muktihari/fit/profile/basetype" "github.com/muktihari/fit/proto" - "golang.org/x/exp/constraints" ) type Numeric interface { - constraints.Integer | constraints.Float + ~int8 | ~int16 | ~int32 | ~int64 | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~float32 | ~float64 } // Apply applies scale and offset on value. diff --git a/profile/filedef/activity_test.go b/profile/filedef/activity_test.go index ace500ed..033fd04d 100644 --- a/profile/filedef/activity_test.go +++ b/profile/filedef/activity_test.go @@ -9,6 +9,8 @@ import ( "testing" "time" + "slices" + "github.com/google/go-cmp/cmp" "github.com/muktihari/fit/factory" "github.com/muktihari/fit/kit/datetime" @@ -18,7 +20,6 @@ import ( "github.com/muktihari/fit/profile/untyped/fieldnum" "github.com/muktihari/fit/profile/untyped/mesgnum" "github.com/muktihari/fit/proto" - "golang.org/x/exp/slices" ) func sortFields(mesgs []proto.Message) { diff --git a/profile/filedef/filedef.go b/profile/filedef/filedef.go index b21b0662..297161fb 100644 --- a/profile/filedef/filedef.go +++ b/profile/filedef/filedef.go @@ -5,11 +5,12 @@ package filedef import ( + "slices" + "github.com/muktihari/fit/profile/mesgdef" "github.com/muktihari/fit/profile/untyped/fieldnum" "github.com/muktihari/fit/profile/untyped/mesgnum" "github.com/muktihari/fit/proto" - "golang.org/x/exp/slices" ) // File is an interface for defining common type file, any defined common file type should implement