use any instead of interface

This commit is contained in:
ston1th 2023-03-21 01:30:56 +01:00
commit 8f350b4b02
5 changed files with 9 additions and 9 deletions

View file

@ -90,7 +90,7 @@ func unixListener(socket string) (sock net.Listener, err error) {
if err != nil {
return
}
err = os.Chmod(socket, 0660)
err = os.Chmod(socket, 0o660)
return
}

View file

@ -85,7 +85,7 @@ func (bs *BoltStore) Restore(r io.Reader) (err error) {
})
}
func (bs *BoltStore) Get(key string, v interface{}) (err error) {
func (bs *BoltStore) Get(key string, v any) (err error) {
err = bs.db.View(func(tx *bolt.Tx) error {
b := tx.Bucket([]byte(defaultBoltBucket)).Get([]byte(key))
if b == nil {
@ -99,7 +99,7 @@ func (bs *BoltStore) Get(key string, v interface{}) (err error) {
return
}
func (bs *BoltStore) Set(key string, v interface{}) error {
func (bs *BoltStore) Set(key string, v any) error {
return bs.db.Update(func(tx *bolt.Tx) (err error) {
var b []byte
if v != nil {

View file

@ -13,13 +13,13 @@ func NewGOB() Marshaler {
return gobMarshaler{}
}
func (gobMarshaler) Marshal(v interface{}) (b []byte, err error) {
func (gobMarshaler) Marshal(v any) (b []byte, err error) {
buf := new(bytes.Buffer)
err = gob.NewEncoder(buf).Encode(v)
b = buf.Bytes()
return
}
func (gobMarshaler) Unmarshal(data []byte, v interface{}) error {
func (gobMarshaler) Unmarshal(data []byte, v any) error {
return gob.NewDecoder(bytes.NewBuffer(data)).Decode(v)
}

View file

@ -3,6 +3,6 @@
package store
type Marshaler interface {
Marshal(v interface{}) ([]byte, error)
Unmarshal(data []byte, v interface{}) error
Marshal(v any) ([]byte, error)
Unmarshal(data []byte, v any) error
}

View file

@ -14,8 +14,8 @@ type Store interface {
Marshaler
Dumper
Restorer
Get(string, interface{}) error
Set(string, interface{}) error
Get(string, any) error
Set(string, any) error
ForEach(func(string, []byte) error) error
ForEachPrefix(string, func(string, []byte) error) error
Delete(string) error