Skip to content

Commit

Permalink
Update to go 1.23
Browse files Browse the repository at this point in the history
  • Loading branch information
rowanseymour committed Sep 16, 2024
1 parent 3a616ad commit 9ec379c
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 26 deletions.
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "GoFlow",
"image": "mcr.microsoft.com/devcontainers/go:1-1.22-bullseye",
"image": "mcr.microsoft.com/devcontainers/go:1-1.23-bullseye",
"features": {
"ghcr.io/devcontainers-contrib/features/pandoc:1": {
"version": "latest"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: CI
on: [push, pull_request]
env:
go-version: "1.22.x"
go-version: "1.23.x"
jobs:
test:
name: Test
Expand Down
8 changes: 5 additions & 3 deletions contactql/inspect.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package contactql

import (
"maps"
"slices"

"github.com/nyaruka/goflow/assets"
"github.com/nyaruka/goflow/utils"
)

// Inspection holds the result of inspecting a query
Expand Down Expand Up @@ -69,8 +71,8 @@ func Inspect(query *ContactQuery) *Inspection {
allowAsGroup := !(attributes[AttributeID] || attributes[AttributeStatus] || attributes[AttributeGroup] || attributes[AttributeFlow] || attributes[AttributeHistory])

return &Inspection{
Attributes: utils.SortedKeys(attributes),
Schemes: utils.SortedKeys(schemes),
Attributes: slices.Sorted(maps.Keys(attributes)),
Schemes: slices.Sorted(maps.Keys(schemes)),
Fields: fieldRefs,
Groups: groupRefs,
AllowAsGroup: allowAsGroup,
Expand Down
4 changes: 3 additions & 1 deletion flows/definition/flow.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package definition
import (
"encoding/json"
"fmt"
"maps"
"slices"

"github.com/Masterminds/semver"
"github.com/nyaruka/gocommon/i18n"
Expand Down Expand Up @@ -268,7 +270,7 @@ func (f *flow) extract() ([]flows.ExtractedTemplate, []flows.ExtractedReference,
})
}

return templates, assetRefs, utils.SortedKeys(parentRefs)
return templates, assetRefs, slices.Sorted(maps.Keys(parentRefs))
}

// extracts all result specs
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/nyaruka/goflow

go 1.22
go 1.23

require (
github.com/Masterminds/semver v1.5.0
Expand All @@ -9,7 +9,7 @@ require (
github.com/blevesearch/segment v0.9.1
github.com/buger/jsonparser v1.1.1
github.com/go-playground/validator/v10 v10.22.0
github.com/nyaruka/gocommon v1.57.1
github.com/nyaruka/gocommon v1.59.0
github.com/sergi/go-diff v1.3.1
github.com/shopspring/decimal v1.4.0
github.com/stretchr/testify v1.9.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ=
github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI=
github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw=
github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
github.com/nyaruka/gocommon v1.57.1 h1:s/9WLZAOUNg0dQHZkgpx8qQMUtNJ2mqzxQhdk1+UBn4=
github.com/nyaruka/gocommon v1.57.1/go.mod h1:wa++Yu/8PEP/HwfvXZrGlKZUCPSJAtSJHeuVsWtLOPM=
github.com/nyaruka/gocommon v1.59.0 h1:XC//IVSOWawBXEZqDiYhqxrIHWo2QPPeCIkAm4n4sY0=
github.com/nyaruka/gocommon v1.59.0/go.mod h1:Upj2DG1iL55YcfF7rve8CRrKGjMaEn0jWUIWbQQgTFQ=
github.com/nyaruka/null/v2 v2.0.3 h1:rdmMRQyVzrOF3Jff/gpU/7BDR9mQX0lcLl4yImsA3kw=
github.com/nyaruka/null/v2 v2.0.3/go.mod h1:OCVeCkCXwrg5/qE6RU0c1oUVZBy+ZDrT+xYg1XSaIWA=
github.com/nyaruka/phonenumbers v1.4.0 h1:ddhWiHnHCIX3n6ETDA58Zq5dkxkjlvgrDWM2OHHPCzU=
Expand Down
10 changes: 0 additions & 10 deletions utils/misc.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
package utils

import (
"slices"

"golang.org/x/exp/constraints"
"golang.org/x/exp/maps"
)

// Set converts a slice to a set (a K > bool map)
Expand All @@ -16,13 +13,6 @@ func Set[K constraints.Ordered](s []K) map[K]bool {
return m
}

// SortedKeys returns the keys of a set in lexical order
func SortedKeys[K constraints.Ordered, V any](m map[K]V) []K {
keys := maps.Keys(m)
slices.Sort(keys)
return keys
}

// Typed is an interface of objects that are marshalled as typed envelopes
type Typed interface {
Type() string
Expand Down
6 changes: 0 additions & 6 deletions utils/misc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,6 @@ import (
"github.com/stretchr/testify/assert"
)

func TestSortedKeys(t *testing.T) {
assert.Equal(t, []string{}, utils.SortedKeys(map[string]bool{}))
assert.Equal(t, []string{"a", "x", "y"}, utils.SortedKeys(map[string]bool{"x": true, "y": true, "a": true}))
assert.Equal(t, []int{3, 5, 6}, utils.SortedKeys(map[int]bool{6: true, 3: true, 5: true}))
}

func TestSet(t *testing.T) {
assert.Equal(t, map[string]bool{}, utils.Set[string](nil))
assert.Equal(t, map[string]bool{}, utils.Set([]string{}))
Expand Down

0 comments on commit 9ec379c

Please sign in to comment.