Skip to content

Commit

Permalink
refactor: set minimal go version to v1.21 (#420)
Browse files Browse the repository at this point in the history
* set minimal go version to go v1.21

* drop golang.org/x/exp dependency

* add unit test for strutil.ToTitle
  • Loading branch information
muktihari authored Sep 12, 2024
1 parent 2a825d2 commit 42bdc4d
Show file tree
Hide file tree
Showing 12 changed files with 54 additions and 14 deletions.
3 changes: 2 additions & 1 deletion cmd/fitactivity/combiner/combiner.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand Down
3 changes: 2 additions & 1 deletion cmd/fitactivity/combiner/combiner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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) {
Expand Down
3 changes: 1 addition & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -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
)

Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand All @@ -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=
2 changes: 1 addition & 1 deletion internal/cmd/benchfit/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module benchfit

go 1.20
go 1.21

require (
github.com/muktihari/fit v0.0.0
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/fitgen/pkg/flagutil/flagutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"os"
"strings"

"golang.org/x/exp/slices"
"slices"
)

func Usage() {
Expand Down
36 changes: 36 additions & 0 deletions internal/cmd/fitgen/pkg/strutil/strutil_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion internal/cmd/fitgen/profile/mesgdef/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
3 changes: 2 additions & 1 deletion internal/cmd/fitgen/profile/untyped/fieldnum/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
3 changes: 1 addition & 2 deletions kit/scaleoffset/scaleoffset.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 2 additions & 1 deletion profile/filedef/activity_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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) {
Expand Down
3 changes: 2 additions & 1 deletion profile/filedef/filedef.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 42bdc4d

Please sign in to comment.