Skip to content

Commit

Permalink
Merge pull request #158 from GeoNet/go1.21
Browse files Browse the repository at this point in the history
Go 1.21
  • Loading branch information
sue-h-gns authored Jan 26, 2024
2 parents 6a3fe51 + ae93559 commit e608565
Show file tree
Hide file tree
Showing 121 changed files with 75,058 additions and 690 deletions.
7 changes: 4 additions & 3 deletions gloria_pb/gloria.pb_test.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package gloria_pb

import (
"google.golang.org/protobuf/proto"
"io/ioutil"
"os"
"sort"
"testing"
"time"

"google.golang.org/protobuf/proto"
)

// TestProto creates an example Gloria proto file for TAUP.
Expand Down Expand Up @@ -66,7 +67,7 @@ Contact: www.geonet.org.nz email: info@geonet.org.nz`,
t.Error(err)
}

err = ioutil.WriteFile("testdata/taup.pb", b, 0600)
err = os.WriteFile("testdata/taup.pb", b, 0600)
if err != nil {
t.Error(err)
}
Expand Down
29 changes: 26 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
module github.com/GeoNet/kit

go 1.16
go 1.21

require (
github.com/aws/aws-sdk-go-v2 v1.22.2
github.com/aws/aws-sdk-go-v2/config v1.15.3
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.14.3 // indirect
github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.11.5
github.com/aws/aws-sdk-go-v2/service/s3 v1.26.5
github.com/aws/aws-sdk-go-v2/service/sns v1.17.4
Expand All @@ -14,8 +13,32 @@ require (
github.com/aws/smithy-go v1.16.0
github.com/gocql/gocql v1.0.0
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da
github.com/golang/protobuf v1.5.2 // indirect
github.com/lib/pq v1.3.0
github.com/stretchr/testify v1.6.1
golang.org/x/text v0.14.0
google.golang.org/protobuf v1.27.1
)

require (
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.4.1 // indirect
github.com/aws/aws-sdk-go-v2/credentials v1.11.2 // indirect
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.14.3 // indirect
github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.9 // indirect
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.3 // indirect
github.com/aws/aws-sdk-go-v2/internal/ini v1.3.10 // indirect
github.com/aws/aws-sdk-go-v2/internal/v4a v1.0.0 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.9.1 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.1.3 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.3 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.13.3 // indirect
github.com/aws/aws-sdk-go-v2/service/sso v1.11.3 // indirect
github.com/aws/aws-sdk-go-v2/service/sts v1.16.3 // indirect
github.com/davecgh/go-spew v1.1.0 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/golang/snappy v0.0.3 // indirect
github.com/hailocab/go-hostpool v0.0.0-20160125115350-e80d13ce29ed // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c // indirect
)
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
Expand Down
7 changes: 6 additions & 1 deletion map180/label.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import (
"bytes"
"fmt"
"strings"

"golang.org/x/text/cases"
"golang.org/x/text/language"
)

type label struct {
Expand Down Expand Up @@ -42,7 +45,9 @@ func labelsToSVG(labels []label) string {

for _, l := range labels {
l.label = strings.Replace(l.label, `Mount`, `Mt`, -1)
l.label = strings.Title(strings.ToLower(l.label))
caser := cases.Title(language.BritishEnglish)
l.label = caser.String(strings.ToLower(l.label))

switch l.featureType {
case 0:
b.WriteString(fmt.Sprintf("<circle cx=\"%d\" cy=\"%d\" r=\"1\" stroke=\"grey\" stroke-width=\"1\" fill=\"lightgrey\" />", l.x, l.y))
Expand Down
17 changes: 8 additions & 9 deletions map180/nzmap/nzmap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package nzmap
import (
"bytes"
"fmt"
"io/ioutil"
"os"
"testing"
)
Expand All @@ -29,7 +28,7 @@ func TestIconWellington(t *testing.T) {

b.WriteString(fmt.Sprintf("<circle cx=\"%d\" cy=\"%d\" r=\"5\" fill=\"black\"/></svg>", p.X(), p.Y()))

if err := ioutil.WriteFile("svg_test/nzicon-wellington.svg", b.Bytes(), 0644); err != nil { // nolint: gosec
if err := os.WriteFile("svg_test/nzicon-wellington.svg", b.Bytes(), 0644); err != nil { // nolint: gosec
t.Fatal(err)
}
}
Expand All @@ -48,7 +47,7 @@ func TestIconRaoul(t *testing.T) {

b.WriteString(fmt.Sprintf("<circle cx=\"%d\" cy=\"%d\" r=\"5\" fill=\"black\"/></svg>", p.X(), p.Y()))

if err := ioutil.WriteFile("svg_test/nzicon-raoul.svg", b.Bytes(), 0644); err != nil { // nolint: gosec
if err := os.WriteFile("svg_test/nzicon-raoul.svg", b.Bytes(), 0644); err != nil { // nolint: gosec
t.Fatal(err)
}
}
Expand All @@ -67,7 +66,7 @@ func TestIconAucklandIsland(t *testing.T) {

b.WriteString(fmt.Sprintf("<circle cx=\"%d\" cy=\"%d\" r=\"5\" fill=\"black\"/></svg>", p.X(), p.Y()))

if err := ioutil.WriteFile("svg_test/nzicon-aucklandisland.svg", b.Bytes(), 0644); err != nil { // nolint: gosec
if err := os.WriteFile("svg_test/nzicon-aucklandisland.svg", b.Bytes(), 0644); err != nil { // nolint: gosec
t.Fatal(err)
}
}
Expand All @@ -86,7 +85,7 @@ func TestIconCanberra(t *testing.T) {

b.WriteString(fmt.Sprintf("<circle cx=\"%d\" cy=\"%d\" r=\"5\" fill=\"black\"/></svg>", p.X(), p.Y()))

if err := ioutil.WriteFile("svg_test/nzicon-canberra.svg", b.Bytes(), 0644); err != nil { // nolint: gosec
if err := os.WriteFile("svg_test/nzicon-canberra.svg", b.Bytes(), 0644); err != nil { // nolint: gosec
t.Fatal(err)
}
}
Expand All @@ -113,7 +112,7 @@ func TestMediumWellington(t *testing.T) {

b.WriteString("</svg>")

if err := ioutil.WriteFile("svg_test/nzmedium-wellington.svg", b.Bytes(), 0644); err != nil { // nolint: gosec
if err := os.WriteFile("svg_test/nzmedium-wellington.svg", b.Bytes(), 0644); err != nil { // nolint: gosec
t.Fatal(err)
}
}
Expand Down Expand Up @@ -141,7 +140,7 @@ func TestMediumIob(t *testing.T) {

b.WriteString("</svg>")

if err := ioutil.WriteFile("svg_test/nzmedium-iob.svg", b.Bytes(), 0644); err != nil { // nolint: gosec
if err := os.WriteFile("svg_test/nzmedium-iob.svg", b.Bytes(), 0644); err != nil { // nolint: gosec
t.Fatal(err)
}
}
Expand Down Expand Up @@ -196,7 +195,7 @@ func TestMediumRegionWellington(t *testing.T) {

b.WriteString("</svg>")

if err := ioutil.WriteFile("svg_test/nzmediumregion-wellington.svg", b.Bytes(), 0644); err != nil { // nolint: gosec
if err := os.WriteFile("svg_test/nzmediumregion-wellington.svg", b.Bytes(), 0644); err != nil { // nolint: gosec
t.Fatal(err)
}
}
Expand Down Expand Up @@ -250,7 +249,7 @@ func TestMediumRegionRaoul(t *testing.T) {

b.WriteString("</svg>")

if err := ioutil.WriteFile("svg_test/nzmediumregion-raoul.svg", b.Bytes(), 0644); err != nil { // nolint: gosec
if err := os.WriteFile("svg_test/nzmediumregion-raoul.svg", b.Bytes(), 0644); err != nil { // nolint: gosec
t.Fatal(err)
}
}
22 changes: 12 additions & 10 deletions map180/nzmap_gen_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build generate
// +build generate

package map180
Expand All @@ -6,11 +7,12 @@ import (
"bytes"
"database/sql"
"fmt"
"github.com/GeoNet/kit/cfg"
_ "github.com/lib/pq"
"io/ioutil"
"log"
"os"
"testing"

"github.com/GeoNet/kit/cfg"
_ "github.com/lib/pq"
)

/*
Expand Down Expand Up @@ -166,7 +168,7 @@ func TestIconNewZealand(t *testing.T) {
}
out.WriteString("}\n")

err = ioutil.WriteFile("nzmap/nzicon.go", out.Bytes(), 0644)
err = os.WriteFile("nzmap/nzicon.go", out.Bytes(), 0644)
if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -225,7 +227,7 @@ func TestIconNewZealandRaoulChathams(t *testing.T) {
}
out.WriteString("}\n")

err = ioutil.WriteFile("nzmap/nzrcicon.go", out.Bytes(), 0644)
err = os.WriteFile("nzmap/nzrcicon.go", out.Bytes(), 0644)
if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -277,7 +279,7 @@ func TestIconNewZealandSouth(t *testing.T) {
}
out.WriteString("}\n")

err = ioutil.WriteFile("nzmap/nzsicon.go", out.Bytes(), 0644)
err = os.WriteFile("nzmap/nzsicon.go", out.Bytes(), 0644)
if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -329,7 +331,7 @@ func TestNewZealand(t *testing.T) {
}
out.WriteString("}\n")

err = ioutil.WriteFile("nzmap/nzmedium.go", out.Bytes(), 0644)
err = os.WriteFile("nzmap/nzmedium.go", out.Bytes(), 0644)
if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -389,7 +391,7 @@ func TestNewZealandRaoulChathams(t *testing.T) {
}
out.WriteString("}\n")

err = ioutil.WriteFile("nzmap/nzrcmedium.go", out.Bytes(), 0644)
err = os.WriteFile("nzmap/nzrcmedium.go", out.Bytes(), 0644)
if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -441,7 +443,7 @@ func TestNewZealandSouth(t *testing.T) {
}
out.WriteString("}\n")

err = ioutil.WriteFile("nzmap/nzsmedium.go", out.Bytes(), 0644)
err = os.WriteFile("nzmap/nzsmedium.go", out.Bytes(), 0644)
if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -499,7 +501,7 @@ func TestNewZealandRaoul(t *testing.T) {
}
out.WriteString("}\n")

err = ioutil.WriteFile("nzmap/nzrmedium.go", out.Bytes(), 0644)
err = os.WriteFile("nzmap/nzrmedium.go", out.Bytes(), 0644)
if err != nil {
t.Fatal(err)
}
Expand Down
3 changes: 1 addition & 2 deletions sc3ml/quake.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package sc3ml
import (
"fmt"
"io"
"io/ioutil"
"time"
)

Expand Down Expand Up @@ -106,7 +105,7 @@ func (q *Quake) Manual() bool {
func FromSC3ML(r io.Reader) (Quake, error) {
var s Seiscomp

b, err := ioutil.ReadAll(r)
b, err := io.ReadAll(r)
if err != nil {
return Quake{}, err
}
Expand Down
10 changes: 6 additions & 4 deletions sc3ml/sc3ml_integration_test.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
//go:build integration
// +build integration

package sc3ml_test

import (
"github.com/GeoNet/kit/sc3ml"
"io/ioutil"
"io"
"os"
"strings"
"testing"

"github.com/GeoNet/kit/sc3ml"
)

// TestUnmarshalIntegration will list and unmarshal all .xml files
Expand All @@ -22,7 +24,7 @@ func TestUnmarshalIntegration(t *testing.T) {
var b []byte
var files []os.FileInfo

if files, err = ioutil.ReadDir("/work/seismcompml07-test"); err != nil {
if files, err = os.ReadDir("/work/seismcompml07-test"); err != nil {
t.Fatal(err)
}

Expand All @@ -34,7 +36,7 @@ func TestUnmarshalIntegration(t *testing.T) {
}
defer f.Close()

if b, err = ioutil.ReadAll(f); err != nil {
if b, err = io.ReadAll(f); err != nil {
t.Fatal(err)
}
f.Close()
Expand Down
15 changes: 8 additions & 7 deletions sc3ml/sc3ml_test.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package sc3ml_test

import (
"github.com/GeoNet/kit/sc3ml"
"io/ioutil"
"os"
"testing"
"time"

"github.com/GeoNet/kit/sc3ml"
)

/*
Expand All @@ -19,7 +20,7 @@ the version. The validating them using the XSDs:
*/
func TestUnmarshal(t *testing.T) {
for _, input := range []string{"2015p768477_0.7.xml", "2015p768477_0.8.xml", "2015p768477_0.9.xml", "2015p768477_0.10.xml", "2015p768477_0.11.xml"} {
b, err := ioutil.ReadFile("testdata/" + input)
b, err := os.ReadFile("testdata/" + input)
if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -262,7 +263,7 @@ func TestUnmarshal(t *testing.T) {

func TestUnmarshall10(t *testing.T) {
for _, input := range []string{"2018p587301-201808060715471135_0.10.xml", "2018p632195-201808222155051312_0.10.xml", "2018p587301-201808060715471135_0.11.xml", "2018p632195-201808222155051312_0.11.xml"} {
b, err := ioutil.ReadFile("testdata/" + input)
b, err := os.ReadFile("testdata/" + input)
if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -307,7 +308,7 @@ func TestUnmarshall10(t *testing.T) {

func TestDecodeSC3ML07CMT(t *testing.T) {
for _, input := range []string{"2016p408314-201606010431276083_0.7.xml", "2016p408314-201606010431276083_0.8.xml", "2016p408314-201606010431276083_0.9.xml", "2016p408314-201606010431276083_0.10.xml", "2016p408314-201606010431276083_0.11.xml"} {
b, err := ioutil.ReadFile("testdata/" + input)
b, err := os.ReadFile("testdata/" + input)
if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -388,7 +389,7 @@ func TestDecodeSC3ML07CMT(t *testing.T) {

func TestUnmarshalUnsupported(t *testing.T) {
for _, input := range []string{"2015p768477_0.4.xml"} {
b, err := ioutil.ReadFile("testdata/" + input)
b, err := os.ReadFile("testdata/" + input)
if err != nil {
t.Fatal(err)
}
Expand All @@ -403,7 +404,7 @@ func TestUnmarshalUnsupported(t *testing.T) {
}

func BenchmarkUnmarshalSeiscompml(b *testing.B) {
by, err := ioutil.ReadFile("testdata/2015p768477_0.7.xml")
by, err := os.ReadFile("testdata/2015p768477_0.7.xml")
if err != nil {
b.Fatal(err)
}
Expand Down
Loading

0 comments on commit e608565

Please sign in to comment.