From 0bc7adf44226ad898f73b253eb5feb40f8d0bcee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20Gill=C3=A9?= Date: Sun, 26 Nov 2023 15:58:03 +0100 Subject: [PATCH 1/4] Replace interface{} with any Introduced in Go 1.18 --- README.md | 10 ++--- badgerdb/badgerdb.go | 4 +- badgerdb/badgerdb_test.go | 2 +- bbolt/bbolt.go | 4 +- bbolt/bbolt_test.go | 2 +- bigcache/bigcache.go | 4 +- bigcache/bigcache_test.go | 2 +- cockroachdb/cockroachdb_test.go | 2 +- consul/consul.go | 4 +- consul/consul_test.go | 2 +- datastore/datastore.go | 4 +- datastore/datastore_test.go | 2 +- dynamodb/dynamodb.go | 4 +- dynamodb/dynamodb_test.go | 2 +- encoding/codec.go | 4 +- encoding/gob.go | 4 +- encoding/json.go | 4 +- encoding/proto/proto.go | 4 +- etcd/etcd.go | 4 +- etcd/etcd_test.go | 5 +-- .../tutorialpb/addressbook.pb.go | 8 ++-- file/file.go | 4 +- file/file_test.go | 2 +- freecache/freecache.go | 4 +- freecache/freecache_test.go | 2 +- gomap/gomap.go | 4 +- gomap/gomap_test.go | 2 +- hazelcast/hazelcast.go | 4 +- hazelcast/hazelcast_test.go | 2 +- ignite/ignite.go | 4 +- ignite/ignite_test.go | 2 +- leveldb/leveldb.go | 4 +- leveldb/leveldb_test.go | 2 +- memcached/memcached.go | 4 +- memcached/memcached_test.go | 2 +- mongodb/mongodb.go | 4 +- mongodb/mongodb_test.go | 2 +- mysql/mysql.go | 4 +- mysql/mysql_test.go | 3 +- noop/noop.go | 4 +- postgresql/postgresql_test.go | 2 +- redis/redis.go | 8 ++-- redis/redis_test.go | 2 +- s3/s3.go | 4 +- s3/s3_test.go | 2 +- sql/sql.go | 4 +- store.go | 6 +-- syncmap/syncmap.go | 4 +- syncmap/syncmap_test.go | 2 +- tablestorage/tablestorage.go | 6 +-- tablestorage/tablestorage_test.go | 2 +- tablestore/tablestore.go | 4 +- tablestore/tablestore_test.go | 2 +- test/test.go | 38 +++++++++---------- util/util.go | 4 +- zookeeper/zookeeper.go | 4 +- zookeeper/zookeeper_test.go | 2 +- 57 files changed, 117 insertions(+), 119 deletions(-) diff --git a/README.md b/README.md index 8f4fdb29..77b33747 100644 --- a/README.md +++ b/README.md @@ -36,8 +36,8 @@ Features ```go type Store interface { - Set(k string, v interface{}) error - Get(k string, v interface{}) (found bool, err error) + Set(k string, v any) error + Get(k string, v any) (found bool, err error) Delete(k string) error Close() error } @@ -103,7 +103,7 @@ For the Godoc of specific implementations, see Date: Sun, 26 Nov 2023 18:15:47 +0100 Subject: [PATCH 2/4] Mention interface{} where appropriate --- README.md | 2 +- redis/redis.go | 4 ++-- store.go | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 77b33747..bc85396f 100644 --- a/README.md +++ b/README.md @@ -103,7 +103,7 @@ For the Godoc of specific implementations, see Date: Sun, 26 Nov 2023 18:19:07 +0100 Subject: [PATCH 3/4] Revert interface{} replacement in generated file --- examples/proto_encoding/tutorialpb/addressbook.pb.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/proto_encoding/tutorialpb/addressbook.pb.go b/examples/proto_encoding/tutorialpb/addressbook.pb.go index a0b81c92..eb7a1abf 100644 --- a/examples/proto_encoding/tutorialpb/addressbook.pb.go +++ b/examples/proto_encoding/tutorialpb/addressbook.pb.go @@ -310,7 +310,7 @@ func file_addressbook_proto_rawDescGZIP() []byte { var file_addressbook_proto_enumTypes = make([]protoimpl.EnumInfo, 1) var file_addressbook_proto_msgTypes = make([]protoimpl.MessageInfo, 3) -var file_addressbook_proto_goTypes = []any{ +var file_addressbook_proto_goTypes = []interface{}{ (Person_PhoneType)(0), // 0: tutorial.Person.PhoneType (*Person)(nil), // 1: tutorial.Person (*AddressBook)(nil), // 2: tutorial.AddressBook @@ -335,7 +335,7 @@ func file_addressbook_proto_init() { return } if !protoimpl.UnsafeEnabled { - file_addressbook_proto_msgTypes[0].Exporter = func(v any, i int) any { + file_addressbook_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*Person); i { case 0: return &v.state @@ -347,7 +347,7 @@ func file_addressbook_proto_init() { return nil } } - file_addressbook_proto_msgTypes[1].Exporter = func(v any, i int) any { + file_addressbook_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*AddressBook); i { case 0: return &v.state @@ -359,7 +359,7 @@ func file_addressbook_proto_init() { return nil } } - file_addressbook_proto_msgTypes[2].Exporter = func(v any, i int) any { + file_addressbook_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*Person_PhoneNumber); i { case 0: return &v.state From 822e5c5279cd5cfabed1ea7b2ed6b1733638c18b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20Gill=C3=A9?= Date: Sun, 26 Nov 2023 18:32:40 +0100 Subject: [PATCH 4/4] Revert import grouping change --- etcd/etcd_test.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/etcd/etcd_test.go b/etcd/etcd_test.go index 259c3804..a07c232a 100644 --- a/etcd/etcd_test.go +++ b/etcd/etcd_test.go @@ -6,10 +6,11 @@ import ( "testing" "time" + clientv3 "go.etcd.io/etcd/client/v3" + "github.com/philippgille/gokv/encoding" "github.com/philippgille/gokv/etcd" "github.com/philippgille/gokv/test" - clientv3 "go.etcd.io/etcd/client/v3" ) // TestClient tests if reading from, writing to and deleting from the store works properly.