Skip to content

Commit

Permalink
Merge pull request #1285 from nyaruka/go1.23
Browse files Browse the repository at this point in the history
Update to go 1.23
  • Loading branch information
rowanseymour authored Sep 16, 2024
2 parents 3a616ad + 09a5e28 commit 35e5f99
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 41 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
7 changes: 5 additions & 2 deletions contactql/inspect.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package contactql

import (
"maps"
"slices"

"github.com/nyaruka/goflow/assets"
"github.com/nyaruka/goflow/utils"
)
Expand Down Expand Up @@ -69,8 +72,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: utils.EnsureNonNil(slices.Sorted(maps.Keys(attributes))),
Schemes: utils.EnsureNonNil(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, utils.EnsureNonNil(slices.Sorted(maps.Keys(parentRefs)))
}

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

go 1.22
go 1.23

require (
github.com/Masterminds/semver v1.5.0
github.com/Shopify/gomail v0.0.0-20220729171026-0784ece65e69
github.com/antlr4-go/antlr/v4 v4.13.1
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/go-playground/validator/v10 v10.22.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
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56
golang.org/x/net v0.27.0
golang.org/x/text v0.16.0
golang.org/x/exp v0.0.0-20240909161429-701f63a606c0
golang.org/x/net v0.29.0
golang.org/x/text v0.18.0
)

require (
Expand All @@ -30,8 +30,8 @@ require (
github.com/nyaruka/null/v2 v2.0.3 // indirect
github.com/nyaruka/phonenumbers v1.4.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
golang.org/x/crypto v0.25.0 // indirect
golang.org/x/sys v0.22.0 // indirect
golang.org/x/crypto v0.27.0 // indirect
golang.org/x/sys v0.25.0 // indirect
google.golang.org/protobuf v1.34.2 // indirect
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
Expand Down
28 changes: 14 additions & 14 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/o
github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
github.com/go-playground/validator/v10 v10.22.0 h1:k6HsTZ0sTnROkhS//R0O+55JgM8C4Bx7ia+JlgcnOao=
github.com/go-playground/validator/v10 v10.22.0/go.mod h1:dbuPbCMFw/DrkbEynArYaCwl3amGuJotoKCe95atGMM=
github.com/go-playground/validator/v10 v10.22.1 h1:40JcKH+bBNGFczGuoBYgX4I6m/i27HYW8P9FDk5PbgA=
github.com/go-playground/validator/v10 v10.22.1/go.mod h1:dbuPbCMFw/DrkbEynArYaCwl3amGuJotoKCe95atGMM=
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/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
Expand All @@ -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 All @@ -56,16 +56,16 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
golang.org/x/crypto v0.25.0 h1:ypSNr+bnYL2YhwoMt2zPxHFmbAN1KZs/njMG3hxUp30=
golang.org/x/crypto v0.25.0/go.mod h1:T+wALwcMOSE0kXgUAnPAHqTLW+XHgcELELW8VaDgm/M=
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 h1:2dVuKD2vS7b0QIHQbpyTISPd0LeHDbnYEryqj5Q1ug8=
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56/go.mod h1:M4RDyNAINzryxdtnbRXRL/OHtkFuWGRjvuhBJpk2IlY=
golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys=
golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE=
golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI=
golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4=
golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI=
golang.org/x/crypto v0.27.0 h1:GXm2NjJrPaiv/h1tb2UH8QfgC/hOf/+z0p6PT8o1w7A=
golang.org/x/crypto v0.27.0/go.mod h1:1Xngt8kV6Dvbssa53Ziq6Eqn0HqbZi5Z6R0ZpwQzt70=
golang.org/x/exp v0.0.0-20240909161429-701f63a606c0 h1:e66Fs6Z+fZTbFBAxKfP3PALWBtpfqks2bwGcexMxgtk=
golang.org/x/exp v0.0.0-20240909161429-701f63a606c0/go.mod h1:2TbTHSBQa924w8M6Xs1QcRcFwyucIwBGpK1p2f1YFFY=
golang.org/x/net v0.29.0 h1:5ORfpBpCs4HzDYoodCDBbwHzdR5UrLBZ3sOnUJmFoHo=
golang.org/x/net v0.29.0/go.mod h1:gLkgy8jTGERgjzMic6DS9+SP0ajcu6Xu3Orq/SpETg0=
golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34=
golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224=
golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg=
google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw=
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc h1:2gGKlE2+asNV9m7xrywl36YYNnBG5ZQ0r/BOOxqPpmk=
Expand Down
15 changes: 7 additions & 8 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,11 +13,13 @@ 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
// Until encoding/json/v2 there's no easy way to ensure nil slices are marshalled as empty arrays
// see https://github.com/golang/go/discussions/63397
func EnsureNonNil[T any](s []T) []T {
if s == nil {
return []T{}
}
return s
}

// Typed is an interface of objects that are marshalled as typed envelopes
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 35e5f99

Please sign in to comment.