diff options
| author | Shulhan <ms@kilabit.info> | 2025-01-23 01:52:09 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2025-01-23 01:52:09 +0700 |
| commit | 605d847b236dde031a2e387e74298d66a27b5e0a (patch) | |
| tree | 269a845eb7d7b32dfa352a89e0fef8b604eb4f7e | |
| parent | 71cbfd0921d8d19baad3042d88146531565232c6 (diff) | |
| download | pakakeh.go-605d847b236dde031a2e387e74298d66a27b5e0a.tar.xz | |
all: replace "interface{}" with "any"
60 files changed, 333 insertions, 324 deletions
diff --git a/lib/clise/clise.go b/lib/clise/clise.go index a3acbbdd..036b8745 100644 --- a/lib/clise/clise.go +++ b/lib/clise/clise.go @@ -1,6 +1,6 @@ -// Copyright 2021, Shulhan <ms@kilabit.info>. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. +// SPDX-FileCopyrightText: 2021 M. Shulhan <ms@kilabit.info> +// +// SPDX-License-Identifier: BSD-3-Clause // Package clise implements circular slice. // A circular slice is a slice that have fixed size. @@ -29,7 +29,7 @@ import ( // Clise define the circular slice implementation. type Clise struct { - v []interface{} + v []any size int last int sync.Mutex @@ -43,7 +43,7 @@ func New(size int) (c *Clise) { return nil } c = &Clise{ - v: make([]interface{}, size), + v: make([]any, size), size: size, } return c @@ -57,7 +57,7 @@ func (c *Clise) Close() error { // Pop remove the last Push()-ed item and return it to caller. // It will return nil if no more item inside it. -func (c *Clise) Pop() (item interface{}) { +func (c *Clise) Pop() (item any) { c.Lock() if c.over { if c.last == 0 { @@ -79,7 +79,7 @@ func (c *Clise) Pop() (item interface{}) { } // Push the item into the slice. -func (c *Clise) Push(src ...interface{}) { +func (c *Clise) Push(src ...any) { var x int c.Lock() for ; x < len(src); x++ { @@ -94,9 +94,9 @@ func (c *Clise) Push(src ...interface{}) { } // RecentSlice return the slice from index zero until the recent item. -func (c *Clise) RecentSlice() (dst []interface{}) { +func (c *Clise) RecentSlice() (dst []any) { c.Lock() - dst = make([]interface{}, c.last) + dst = make([]any, c.last) copy(dst, c.v[:c.last]) c.Unlock() return dst @@ -112,7 +112,7 @@ func (c *Clise) Reset() { // Slice return the content of circular slice as slice in the order of the // last item to the recent item. -func (c *Clise) Slice() (dst []interface{}) { +func (c *Clise) Slice() (dst []any) { var ( end = c.size @@ -123,10 +123,10 @@ func (c *Clise) Slice() (dst []interface{}) { defer c.Unlock() if c.over { - dst = make([]interface{}, c.size) + dst = make([]any, c.size) start = c.last } else { - dst = make([]interface{}, c.last) + dst = make([]any, c.last) end = c.last } @@ -168,7 +168,7 @@ func (c *Clise) WriteString(s string) (n int, err error) { func (c *Clise) UnmarshalJSON(jsonb []byte) (err error) { var ( logp = `UnmarshalJSON` - array = make([]interface{}, 0) + array = make([]any, 0) ) err = json.Unmarshal(jsonb, &array) @@ -178,7 +178,7 @@ func (c *Clise) UnmarshalJSON(jsonb []byte) (err error) { if c.size == 0 { c.size = len(array) - c.v = make([]interface{}, c.size) + c.v = make([]any, c.size) } c.Push(array...) diff --git a/lib/clise/clise_example_test.go b/lib/clise/clise_example_test.go index b63655d5..422447e0 100644 --- a/lib/clise/clise_example_test.go +++ b/lib/clise/clise_example_test.go @@ -1,3 +1,7 @@ +// SPDX-FileCopyrightText: 2021 M. Shulhan <ms@kilabit.info> +// +// SPDX-License-Identifier: BSD-3-Clause + package clise import "fmt" @@ -5,7 +9,7 @@ import "fmt" func ExampleClise_Pop() { var ( c = New(5) - item interface{} + item any ) c.Push(1, 2, 3, 4, 5, 6) diff --git a/lib/contact/yahoo/field.go b/lib/contact/yahoo/field.go index 3c07c69b..f10db06a 100644 --- a/lib/contact/yahoo/field.go +++ b/lib/contact/yahoo/field.go @@ -1,6 +1,6 @@ -// Copyright 2018, Shulhan <ms@kilabit.info>. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. +// SPDX-FileCopyrightText: 2018 M. Shulhan <ms@kilabit.info> +// +// SPDX-License-Identifier: BSD-3-Clause package yahoo @@ -25,9 +25,9 @@ const ( // Field define a composite attribute in Contact. // Known value for Type: "phone", "name", "address". type Field struct { - Type string `json:"type"` - Value interface{} `json:"value"` - Flags []string `json:"flags"` + Type string `json:"type"` + Value any `json:"value"` + Flags []string `json:"flags"` // Ignored fields for speedup. @@ -39,14 +39,14 @@ type Field struct { // getValueType will return the Go type of field's Value. func (field *Field) getValueType() ( - vmap map[string]interface{}, + vmap map[string]any, vstr string, ok bool, ) { ok = true switch v := field.Value.(type) { - case map[string]interface{}: + case map[string]any: vmap = v case string: vstr = v @@ -66,7 +66,7 @@ func (field *Field) getFlag() string { } // decodeAddress will convert Yahoo address format to contact address format. -func (field *Field) decodeAddress(flag string, vmap map[string]interface{}) ( +func (field *Field) decodeAddress(flag string, vmap map[string]any) ( adr contact.Address, ) { adr = contact.Address{ diff --git a/lib/dns/resource_record.go b/lib/dns/resource_record.go index d7762e9a..88047f1d 100644 --- a/lib/dns/resource_record.go +++ b/lib/dns/resource_record.go @@ -20,7 +20,7 @@ import ( // resource record has the following format: type ResourceRecord struct { // Value hold the generic, unpacked rdata based on Type. - Value interface{} + Value any // A domain name to which this resource record pertains. Name string diff --git a/lib/dns/udp_client_pool.go b/lib/dns/udp_client_pool.go index 8eaee5df..4b0a75de 100644 --- a/lib/dns/udp_client_pool.go +++ b/lib/dns/udp_client_pool.go @@ -1,6 +1,6 @@ -// Copyright 2019, Shulhan <ms@kilabit.info>. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. +// SPDX-FileCopyrightText: 2019 M. Shulhan <ms@kilabit.info> +// +// SPDX-License-Identifier: BSD-3-Clause package dns @@ -62,7 +62,7 @@ func NewUDPClientPool(nameServers []string) (ucp *UDPClientPool, err error) { } // newClient create a new udp client. -func (ucp *UDPClientPool) newClient() interface{} { +func (ucp *UDPClientPool) newClient() any { var ( cl *UDPClient err error @@ -92,7 +92,7 @@ func (ucp *UDPClientPool) Get() *UDPClient { // // WARNING: any client connection that call Send(), MUST call Recv() // before putting client back to pool. You have been warned. -func (ucp *UDPClientPool) Put(cl interface{}) { +func (ucp *UDPClientPool) Put(cl any) { if cl != nil { ucp.pool.Put(cl) } diff --git a/lib/dsv/configinterface.go b/lib/dsv/configinterface.go index 04ea269c..2c5bad53 100644 --- a/lib/dsv/configinterface.go +++ b/lib/dsv/configinterface.go @@ -1,3 +1,7 @@ +// SPDX-FileCopyrightText: 2018 M. Shulhan <ms@kilabit.info> +// +// SPDX-License-Identifier: BSD-3-Clause + package dsv import ( @@ -13,7 +17,7 @@ type ConfigInterface interface { } // ConfigOpen configuration file and initialize the attributes. -func ConfigOpen(rw interface{}, fcfg string) error { +func ConfigOpen(rw any, fcfg string) error { cfg, e := os.ReadFile(fcfg) if nil != e { @@ -28,7 +32,7 @@ func ConfigOpen(rw interface{}, fcfg string) error { } // ConfigParse from JSON string. -func ConfigParse(rw interface{}, cfg []byte) error { +func ConfigParse(rw any, cfg []byte) error { return json.Unmarshal(cfg, rw) } diff --git a/lib/dsv/dsv.go b/lib/dsv/dsv.go index 420b4221..f9dd859c 100644 --- a/lib/dsv/dsv.go +++ b/lib/dsv/dsv.go @@ -1,6 +1,6 @@ -// Copyright 2015-2018, Shulhan <ms@kilabit.info>. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. +// SPDX-FileCopyrightText: 2015 M. Shulhan <ms@kilabit.info> +// +// SPDX-License-Identifier: BSD-3-Clause // Package dsv is a library for working with delimited separated value (DSV). // @@ -58,7 +58,7 @@ type ReadWriter struct { } // New create a new ReadWriter object. -func New(config string, dataset interface{}) (rw *ReadWriter, e error) { +func New(config string, dataset any) (rw *ReadWriter, e error) { rw = &ReadWriter{} e = rw.Reader.Init(config, dataset) diff --git a/lib/dsv/dsvinterface.go b/lib/dsv/dsvinterface.go index 048de4b7..0249dd5f 100644 --- a/lib/dsv/dsvinterface.go +++ b/lib/dsv/dsvinterface.go @@ -1,6 +1,6 @@ -// Copyright 2015-2018, Shulhan <ms@kilabit.info>. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. +// SPDX-FileCopyrightText: 2015 M. Shulhan <ms@kilabit.info> +// +// SPDX-License-Identifier: BSD-3-Clause package dsv @@ -14,7 +14,7 @@ import ( // Return the reader contained data or error if failed. // Reader object upon returned has been closed, so if one need to read all // data in it simply set the `MaxRows` to `-1` in config file. -func SimpleRead(fcfg string, dataset interface{}) ( +func SimpleRead(fcfg string, dataset any) ( reader ReaderInterface, e error, ) { @@ -60,7 +60,7 @@ func SimpleWrite(reader ReaderInterface, fcfg string) (nrows int, e error) { // - "DatasetMode" to "columns" to speeding up process. // // This function return the merged reader or error if failed. -func SimpleMerge(fin1, fin2 string, dataset1, dataset2 interface{}) ( +func SimpleMerge(fin1, fin2 string, dataset1, dataset2 any) ( ReaderInterface, error, ) { diff --git a/lib/dsv/reader.go b/lib/dsv/reader.go index 65334d95..4bde7060 100644 --- a/lib/dsv/reader.go +++ b/lib/dsv/reader.go @@ -1,6 +1,6 @@ -// Copyright 2015-2018, Shulhan <ms@kilabit.info>. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. +// SPDX-FileCopyrightText: 2015 M. Shulhan <ms@kilabit.info> +// +// SPDX-License-Identifier: BSD-3-Clause package dsv @@ -65,7 +65,7 @@ const ( // Thats it. type Reader struct { // Dataset contains the content of input file after read. - dataset interface{} + dataset any // fRead is read descriptor. fRead *os.File @@ -136,7 +136,7 @@ type Reader struct { } // NewReader create and initialize new instance of DSV Reader with default values. -func NewReader(config string, dataset interface{}) (reader *Reader, e error) { +func NewReader(config string, dataset any) (reader *Reader, e error) { reader = &Reader{ Input: "", Skip: 0, @@ -173,7 +173,7 @@ func NewReader(config string, dataset interface{}) (reader *Reader, e error) { // // (7) Open rejected file. // (8) Open input file. -func (reader *Reader) Init(fcfg string, dataset interface{}) (e error) { +func (reader *Reader) Init(fcfg string, dataset any) (e error) { // (1) if dataset == nil { dataset = reader.GetDataset() @@ -533,7 +533,7 @@ func (reader *Reader) IsEqual(other *Reader) bool { } // GetDataset return reader dataset. -func (reader *Reader) GetDataset() interface{} { +func (reader *Reader) GetDataset() any { return reader.dataset } diff --git a/lib/dsv/readerinterface.go b/lib/dsv/readerinterface.go index 736b999d..c19115ab 100644 --- a/lib/dsv/readerinterface.go +++ b/lib/dsv/readerinterface.go @@ -1,6 +1,6 @@ -// Copyright 2015-2018, Shulhan <ms@kilabit.info>. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. +// SPDX-FileCopyrightText: 2015 M. Shulhan <ms@kilabit.info> +// +// SPDX-License-Identifier: BSD-3-Clause package dsv @@ -46,7 +46,7 @@ type ReaderInterface interface { Reject(line []byte) (int, error) Close() error - GetDataset() interface{} + GetDataset() any MergeColumns(ReaderInterface) } diff --git a/lib/errors/errors.go b/lib/errors/errors.go index ae339241..3fc38cbd 100644 --- a/lib/errors/errors.go +++ b/lib/errors/errors.go @@ -1,6 +1,6 @@ -// Copyright 2018, Shulhan <ms@kilabit.info>. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. +// SPDX-FileCopyrightText: 2018 M. Shulhan <ms@kilabit.info> +// +// SPDX-License-Identifier: BSD-3-Clause // Package errors provide an error type with code. package errors @@ -51,7 +51,7 @@ func (e *E) Error() string { } // As set the target to e only if only target is **E. -func (e *E) As(target interface{}) bool { +func (e *E) As(target any) bool { _, ok := target.(**E) if ok { val := reflect.ValueOf(target) diff --git a/lib/http/endpoint_response.go b/lib/http/endpoint_response.go index 64b539e1..c467677b 100644 --- a/lib/http/endpoint_response.go +++ b/lib/http/endpoint_response.go @@ -1,6 +1,6 @@ -// Copyright 2021, Shulhan <ms@kilabit.info>. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. +// SPDX-FileCopyrightText: 2021 M. Shulhan <ms@kilabit.info> +// +// SPDX-License-Identifier: BSD-3-Clause package http @@ -17,7 +17,7 @@ import liberrors "git.sr.ht/~shulhan/pakakeh.go/lib/errors" // // See the example below on how to use it with [Endpoint.Call] handler. type EndpointResponse struct { - Data interface{} `json:"data,omitempty"` + Data any `json:"data,omitempty"` liberrors.E diff --git a/lib/http/form.go b/lib/http/form.go index 824a683b..e746b403 100644 --- a/lib/http/form.go +++ b/lib/http/form.go @@ -1,6 +1,6 @@ -// Copyright 2022, Shulhan <ms@kilabit.info>. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. +// SPDX-FileCopyrightText: 2022 M. Shulhan <ms@kilabit.info> +// +// SPDX-License-Identifier: BSD-3-Clause package http @@ -149,7 +149,7 @@ func MarshalForm(in any) (out url.Values, err error) { // not a pointer to a struct). // It will not return an error if one of the input value is not match with // field type. -func UnmarshalForm(in url.Values, out interface{}) (err error) { +func UnmarshalForm(in url.Values, out any) (err error) { var ( logp = `UnmarshalForm` vout = reflect.ValueOf(out) diff --git a/lib/ini/ini.go b/lib/ini/ini.go index 7bab0039..47eeb382 100644 --- a/lib/ini/ini.go +++ b/lib/ini/ini.go @@ -1,6 +1,6 @@ -// Copyright 2018, Shulhan <ms@kilabit.info>. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. +// SPDX-FileCopyrightText: 2018 M. Shulhan <ms@kilabit.info> +// +// SPDX-License-Identifier: BSD-3-Clause package ini @@ -109,7 +109,7 @@ func Parse(text []byte) (in *Ini, err error) { // // One exception to above rule is map type. // A map's key will override the key defined in tag. -func Marshal(v interface{}) (b []byte, err error) { +func Marshal(v any) (b []byte, err error) { rtipe := reflect.TypeOf(v) rvalue := reflect.ValueOf(v) kind := rtipe.Kind() @@ -313,7 +313,7 @@ func (in *Ini) marshalStruct( // struct of `v`. // All the properties and specifications of field's tag follow the Marshal // function. -func Unmarshal(b []byte, v interface{}) (err error) { +func Unmarshal(b []byte, v any) (err error) { ini, err := Parse(b) if err != nil { return err @@ -324,7 +324,7 @@ func Unmarshal(b []byte, v interface{}) (err error) { // Unmarshal store the value from configuration, based on `ini` tag, into a // struct pointed by interface `v`. -func (in *Ini) Unmarshal(v interface{}) (err error) { +func (in *Ini) Unmarshal(v any) (err error) { rtipe := reflect.TypeOf(v) rvalue := reflect.ValueOf(v) kind := rtipe.Kind() diff --git a/lib/ini/ini_test.go b/lib/ini/ini_test.go index b50869cc..db27ae7b 100644 --- a/lib/ini/ini_test.go +++ b/lib/ini/ini_test.go @@ -1,6 +1,6 @@ -// Copyright 2018, Shulhan <ms@kilabit.info>. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. +// SPDX-FileCopyrightText: 2018 M. Shulhan <ms@kilabit.info> +// +// SPDX-License-Identifier: BSD-3-Clause package ini @@ -100,7 +100,7 @@ func TestData(t *testing.T) { gotC = &StructC{} gotMap = &StructMap{} - obj interface{} + obj any gotOut []byte err error ) diff --git a/lib/ini/tag_struct_field_test.go b/lib/ini/tag_struct_field_test.go index ab962dca..3d967946 100644 --- a/lib/ini/tag_struct_field_test.go +++ b/lib/ini/tag_struct_field_test.go @@ -1,6 +1,6 @@ -// Copyright 2021, Shulhan <ms@kilabit.info>. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. +// SPDX-FileCopyrightText: 2021 M. Shulhan <ms@kilabit.info> +// +// SPDX-License-Identifier: BSD-3-Clause package ini @@ -45,7 +45,7 @@ func TestUnpackStruct(t *testing.T) { Bool bool `ini:"section::bool"` } - var v interface{} = &T{ + var v any = &T{ PtrStruct: &U{}, } @@ -92,7 +92,7 @@ func TestUnpackStruct_embedded(t *testing.T) { XX byte `ini:"c::xx"` } - var v interface{} = &C{} + var v any = &C{} rtype := reflect.TypeOf(v) rval := reflect.ValueOf(v) diff --git a/lib/json/json.go b/lib/json/json.go index 081246e5..84df191d 100644 --- a/lib/json/json.go +++ b/lib/json/json.go @@ -1,6 +1,6 @@ -// Copyright 2020, Shulhan <ms@kilabit.info>. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. +// SPDX-FileCopyrightText: 2020 M. Shulhan <ms@kilabit.info> +// +// SPDX-License-Identifier: BSD-3-Clause // Package json provide a library for working with JSON. // @@ -101,12 +101,12 @@ func EscapeString(in string) string { return string(outb) } -// ToMapStringFloat64 convert the map of string-interface{} into map of +// ToMapStringFloat64 convert the map of string-any into map of // string-float64. // This function convert the map's key to lower-cases and ignore zero value in -// interface{}. -// The interface{} value only accept basic numeric types and slice of byte. -func ToMapStringFloat64(in map[string]interface{}) (out map[string]float64, err error) { +// any. +// The any value only accept basic numeric types and slice of byte. +func ToMapStringFloat64(in map[string]any) (out map[string]float64, err error) { out = make(map[string]float64, len(in)) for k, v := range in { diff --git a/lib/json/json_test.go b/lib/json/json_test.go index 5f3551dd..dac10da5 100644 --- a/lib/json/json_test.go +++ b/lib/json/json_test.go @@ -1,6 +1,6 @@ -// Copyright 2020, Shulhan <ms@kilabit.info>. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. +// SPDX-FileCopyrightText: 2020 M. Shulhan <ms@kilabit.info> +// +// SPDX-License-Identifier: BSD-3-Clause package json @@ -44,7 +44,7 @@ func TestEscapeString(t *testing.T) { } func TestToMapStringFloat64(t *testing.T) { - in := map[string]interface{}{ + in := map[string]any{ "string": "1", "zero": "0", "byte": byte(3), diff --git a/lib/math/big/float.go b/lib/math/big/float.go index 336cf8b5..3e227f02 100644 --- a/lib/math/big/float.go +++ b/lib/math/big/float.go @@ -1,6 +1,6 @@ -// Copyright 2020, Shulhan <ms@kilabit.info>. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. +// SPDX-FileCopyrightText: 2020 M. Shulhan <ms@kilabit.info> +// +// SPDX-License-Identifier: BSD-3-Clause package big @@ -35,7 +35,7 @@ type Float struct { // AddFloat return the rounded sum `f[0]+f[1]+...`. // It will return nil if the first parameter is not convertable to Float. -func AddFloat(f ...interface{}) *Float { +func AddFloat(f ...any) *Float { if len(f) == 0 { return nil } @@ -55,7 +55,7 @@ func AddFloat(f ...interface{}) *Float { // NewFloat create and initialize new Float with default bit precision, // and rounding mode. -func NewFloat(v interface{}) *Float { +func NewFloat(v any) *Float { return toFloat(v) } @@ -70,7 +70,7 @@ func CreateFloat(v float64) Float { // MulFloat return the result of multiplication `f*g`. // It will return nil if `f` or `g` is not convertible to Float. -func MulFloat(f, g interface{}) *Float { +func MulFloat(f, g any) *Float { ff := toFloat(f) if ff == nil { return nil @@ -104,7 +104,7 @@ func ParseFloat(s string) (f *Float, err error) { } // QuoFloat return the quotient of `f/g` as new Float. -func QuoFloat(f, g interface{}) *Float { +func QuoFloat(f, g any) *Float { ff := toFloat(f) if ff == nil { return nil @@ -125,7 +125,7 @@ func SubFloat(f, g *Float) *Float { } // Add sets f to `f+g` and return the f as the result. -func (f *Float) Add(g interface{}) *Float { +func (f *Float) Add(g any) *Float { gf := toFloat(g) if gf == nil { return nil @@ -148,7 +148,7 @@ func (f *Float) Int64() int64 { } // IsEqual will return true if `f == g`. -func (f *Float) IsEqual(g interface{}) bool { +func (f *Float) IsEqual(g any) bool { gf := toFloat(g) if gf == nil { return false @@ -157,7 +157,7 @@ func (f *Float) IsEqual(g interface{}) bool { } // IsGreater will return true if `f > g`. -func (f *Float) IsGreater(g interface{}) bool { +func (f *Float) IsGreater(g any) bool { gf := toFloat(g) if gf == nil { return false @@ -166,7 +166,7 @@ func (f *Float) IsGreater(g interface{}) bool { } // IsGreaterOrEqual will return true if `f >= g`. -func (f *Float) IsGreaterOrEqual(g interface{}) bool { +func (f *Float) IsGreaterOrEqual(g any) bool { gf := toFloat(g) if gf == nil { return false @@ -175,7 +175,7 @@ func (f *Float) IsGreaterOrEqual(g interface{}) bool { } // IsLess will return true if `f < g`. -func (f *Float) IsLess(g interface{}) bool { +func (f *Float) IsLess(g any) bool { gf := toFloat(g) if gf == nil { return false @@ -184,7 +184,7 @@ func (f *Float) IsLess(g interface{}) bool { } // IsLessOrEqual will return true if `f <= g`. -func (f *Float) IsLessOrEqual(g interface{}) bool { +func (f *Float) IsLessOrEqual(g any) bool { gf := toFloat(g) if gf == nil { return false @@ -210,7 +210,7 @@ func (f *Float) MarshalJSON() ([]byte, error) { // Mul sets f to product of `f * g` and return the result as f. // If g is not convertible to Float it will return nil. -func (f *Float) Mul(g interface{}) *Float { +func (f *Float) Mul(g any) *Float { gf := toFloat(g) if gf == nil { return nil @@ -232,7 +232,7 @@ func (f *Float) ParseFloat(s string) (err error) { // Quo sets f to quotient of `f/g` and return the result as f. // If g is not convertible to Float it will return nil. -func (f *Float) Quo(g interface{}) *Float { +func (f *Float) Quo(g any) *Float { gf := toFloat(g) if gf == nil { return nil @@ -261,7 +261,7 @@ func (f *Float) String() string { } // Sub sets f to rounded difference `f-g` and return f. -func (f *Float) Sub(g interface{}) *Float { +func (f *Float) Sub(g any) *Float { gf := toFloat(g) if gf == nil { return nil @@ -280,7 +280,7 @@ func (f *Float) UnmarshalJSON(in []byte) (err error) { } // toFloat convert v type to Float or nil if v type is unknown. -func toFloat(g interface{}) (out *Float) { +func toFloat(g any) (out *Float) { out = &Float{} out.SetPrec(DefaultBitPrecision).SetMode(DefaultRoundingMode) diff --git a/lib/math/big/float_test.go b/lib/math/big/float_test.go index e7551f97..a8e578d4 100644 --- a/lib/math/big/float_test.go +++ b/lib/math/big/float_test.go @@ -1,6 +1,6 @@ -// Copyright 2020, Shulhan <ms@kilabit.info>. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. +// SPDX-FileCopyrightText: 2020 M. Shulhan <ms@kilabit.info> +// +// SPDX-License-Identifier: BSD-3-Clause package big @@ -30,7 +30,7 @@ func TestFloat_IsEqual(t *testing.T) { f := NewFloat(1) cases := []struct { - g interface{} + g any exp bool }{{ g: byte(1), diff --git a/lib/math/big/int.go b/lib/math/big/int.go index bfb13bb7..1f6b08d5 100644 --- a/lib/math/big/int.go +++ b/lib/math/big/int.go @@ -1,6 +1,6 @@ -// Copyright 2021, Shulhan <ms@kilabit.info>. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. +// SPDX-FileCopyrightText: 2021 M. Shulhan <ms@kilabit.info> +// +// SPDX-License-Identifier: BSD-3-Clause package big @@ -21,7 +21,7 @@ type Int struct { // NewInt create and initialize new Int value from v or nil if v is invalid // type that cannot be converted to Int. -func NewInt(v interface{}) (i *Int) { +func NewInt(v any) (i *Int) { i = &Int{} got := toInt(v, i) @@ -32,7 +32,7 @@ func NewInt(v interface{}) (i *Int) { } // Add set the i value to i + v and return the i as the result. -func (i *Int) Add(v interface{}) *Int { +func (i *Int) Add(v any) *Int { vv := toInt(v, nil) if vv == nil { // Its equal to `i+0` @@ -43,7 +43,7 @@ func (i *Int) Add(v interface{}) *Int { } // IsGreater will return true if i > v. -func (i *Int) IsGreater(v interface{}) bool { +func (i *Int) IsGreater(v any) bool { vv := toInt(v, nil) if vv == nil { return false @@ -52,7 +52,7 @@ func (i *Int) IsGreater(v interface{}) bool { } // IsLess will return true if i < v. -func (i *Int) IsLess(v interface{}) bool { +func (i *Int) IsLess(v any) bool { vv := toInt(v, nil) if vv == nil { return false @@ -84,7 +84,7 @@ func (i *Int) MarshalJSON() ([]byte, error) { } // Scan implement the database's sql.Scan interface. -func (i *Int) Scan(src interface{}) error { +func (i *Int) Scan(src any) error { got := toInt(src, i) if got == nil { return fmt.Errorf("Int.Scan: unknown type %T", src) @@ -114,7 +114,7 @@ func (i *Int) Value() (driver.Value, error) { // toInt convert any type to Int or nil if type is unknown. // If in is not nil, it will be set to out. -func toInt(v interface{}, in *Int) (out *Int) { +func toInt(v any, in *Int) (out *Int) { out = &Int{} switch v := v.(type) { diff --git a/lib/math/big/int_test.go b/lib/math/big/int_test.go index 61cf1a92..d079111d 100644 --- a/lib/math/big/int_test.go +++ b/lib/math/big/int_test.go @@ -1,6 +1,6 @@ -// Copyright 2021, Shulhan <ms@kilabit.info>. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. +// SPDX-FileCopyrightText: 2021 M. Shulhan <ms@kilabit.info> +// +// SPDX-License-Identifier: BSD-3-Clause package big @@ -13,7 +13,7 @@ import ( func TestNewInt(t *testing.T) { cases := []struct { - v interface{} + v any exp string }{{ v: []byte("123.45"), diff --git a/lib/math/big/rat.go b/lib/math/big/rat.go index 4491f67d..db2b6049 100644 --- a/lib/math/big/rat.go +++ b/lib/math/big/rat.go @@ -1,6 +1,6 @@ -// Copyright 2020, Shulhan <ms@kilabit.info>. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. +// SPDX-FileCopyrightText: 2020 M. Shulhan <ms@kilabit.info> +// +// SPDX-License-Identifier: BSD-3-Clause package big @@ -25,7 +25,7 @@ type Rat struct { // AddRat return the sum of `f[0]+f[1]+...`. // It will return nil if the first parameter is not convertable to Rat. -func AddRat(f ...interface{}) *Rat { +func AddRat(f ...any) *Rat { if len(f) == 0 { return nil } @@ -48,13 +48,13 @@ func AddRat(f ...interface{}) *Rat { // // Empty string or empty []byte still considered as valid, and it will return // it as zero. -func NewRat(v interface{}) (r *Rat) { +func NewRat(v any) (r *Rat) { return toRat(v) } // MulRat return the result of multiplication `f[0]*f[1]*...`. // It will return nil if the first parameter is not convertable to Rat. -func MulRat(f ...interface{}) *Rat { +func MulRat(f ...any) *Rat { if len(f) == 0 { return nil } @@ -77,7 +77,7 @@ func MulRat(f ...interface{}) *Rat { // It will return nil if the first parameter is not convertable to Rat. // If the second or rest of parameters can not be converted to Rat or zero it // will return nil instead of panic. -func QuoRat(f ...interface{}) *Rat { +func QuoRat(f ...any) *Rat { if len(f) == 0 { return nil } @@ -97,7 +97,7 @@ func QuoRat(f ...interface{}) *Rat { // SubRat return the result of subtraction `f[0]-f[1]-...` as new Rat. // It will return nil if the first parameter is not convertable to Rat. -func SubRat(f ...interface{}) *Rat { +func SubRat(f ...any) *Rat { if len(f) == 0 { return nil } @@ -126,7 +126,7 @@ func (r *Rat) Abs() *Rat { // Add sets r to `r+g` and return the r as the result. // If g is not convertable to Rat it will equal to r+0. -func (r *Rat) Add(g interface{}) *Rat { +func (r *Rat) Add(g any) *Rat { if r == nil { return nil } @@ -184,7 +184,7 @@ func (r *Rat) Int64() int64 { // Unlike the standard Cmp(), if the first call to Cmp is not 0, it will try // to compare the string values of r and g, truncated by // DefaultDigitPrecision. -func (r *Rat) IsEqual(g interface{}) bool { +func (r *Rat) IsEqual(g any) bool { y := toRat(g) if y == nil { return r == nil @@ -203,7 +203,7 @@ func (r *Rat) IsEqual(g interface{}) bool { // IsGreater will return true if `r > g`. // If g is not convertable to Rat it will return false. -func (r *Rat) IsGreater(g interface{}) bool { +func (r *Rat) IsGreater(g any) bool { if r == nil { return false } @@ -216,7 +216,7 @@ func (r *Rat) IsGreater(g interface{}) bool { // IsGreaterOrEqual will return true if `r >= g`. // If g is not convertable to Rat it will return false. -func (r *Rat) IsGreaterOrEqual(g interface{}) bool { +func (r *Rat) IsGreaterOrEqual(g any) bool { if r == nil { return false } @@ -237,7 +237,7 @@ func (r *Rat) IsGreaterThanZero() bool { // IsLess will return true if `r < g`. // If r is nill or g is not convertable to Rat it will return false. -func (r *Rat) IsLess(g interface{}) bool { +func (r *Rat) IsLess(g any) bool { if r == nil { return false } @@ -250,7 +250,7 @@ func (r *Rat) IsLess(g interface{}) bool { // IsLessOrEqual will return true if `r <= g`. // It r is nil or g is not convertable to Rat it will return false. -func (r *Rat) IsLessOrEqual(g interface{}) bool { +func (r *Rat) IsLessOrEqual(g any) bool { if r == nil { return false } @@ -298,7 +298,7 @@ func (r *Rat) MarshalJSON() ([]byte, error) { // Mul sets r to product of `r * g` and return the result as r. // If g is not convertible to Rat it will return nil. -func (r *Rat) Mul(g interface{}) *Rat { +func (r *Rat) Mul(g any) *Rat { y := toRat(g) if y == nil { return nil @@ -316,7 +316,7 @@ func (r *Rat) Mul(g interface{}) *Rat { // Quo sets r to quotient of `r/g` and return the result as r. // If r is nil or g is not convertible to Rat or zero it will return nil. -func (r *Rat) Quo(g interface{}) *Rat { +func (r *Rat) Quo(g any) *Rat { if r == nil { return nil } @@ -383,7 +383,7 @@ func (r *Rat) RoundToZero(prec int) *Rat { } // Scan implement the database's sql.Scan interface. -func (r *Rat) Scan(v interface{}) error { +func (r *Rat) Scan(v any) error { got := toRat(v) if got == nil { return fmt.Errorf("Rat.Scan: unknown type %T", v) @@ -426,7 +426,7 @@ func (r *Rat) String() string { // Sub sets r to rounded difference `r-g` and return r. // If g is not convertable to Rat, it will return as r-0. -func (r *Rat) Sub(g interface{}) *Rat { +func (r *Rat) Sub(g any) *Rat { if r == nil { return nil } @@ -464,7 +464,7 @@ func (r *Rat) Value() (driver.Value, error) { } // toRat convert v type to Rat or nil if v type is unknown. -func toRat(g interface{}) (out *Rat) { +func toRat(g any) (out *Rat) { out = &Rat{} switch v := g.(type) { diff --git a/lib/math/big/rat_example_test.go b/lib/math/big/rat_example_test.go index d1669765..602041de 100644 --- a/lib/math/big/rat_example_test.go +++ b/lib/math/big/rat_example_test.go @@ -1,6 +1,6 @@ -// Copyright 2021, Shulhan <ms@kilabit.info>. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. +// SPDX-FileCopyrightText: 2021 M. Shulhan <ms@kilabit.info> +// +// SPDX-License-Identifier: BSD-3-Clause package big @@ -49,7 +49,7 @@ func ExampleNewRat() { stdRat big.Rat nilRat *Rat ) - inputs := []interface{}{ + inputs := []any{ nil, []byte{}, "", @@ -576,7 +576,7 @@ func ExampleRat_Scan() { err error ) - inputs := []interface{}{ + inputs := []any{ 1234, nil, "0.0001", @@ -599,7 +599,7 @@ func ExampleRat_Scan() { } func ExampleRat_String() { - inputs := []interface{}{ + inputs := []any{ nil, "12345", "0.00000000", @@ -677,7 +677,7 @@ func ExampleRat_UnmarshalJSON_withStruct() { } func ExampleRat_Value() { - inputs := []interface{}{ + inputs := []any{ nil, 0, 1.2345, diff --git a/lib/memfs/node.go b/lib/memfs/node.go index 5de22c54..ab75be68 100644 --- a/lib/memfs/node.go +++ b/lib/memfs/node.go @@ -1,4 +1,5 @@ // SPDX-FileCopyrightText: 2018 M. Shulhan <ms@kilabit.info> +// // SPDX-License-Identifier: BSD-3-Clause package memfs @@ -369,7 +370,7 @@ func (node *Node) Stat() (os.FileInfo, error) { } // Sys return the underlying data source (can return nil). -func (node *Node) Sys() interface{} { +func (node *Node) Sys() any { return node } diff --git a/lib/mining/classifier/cart/cart.go b/lib/mining/classifier/cart/cart.go index b47a4852..2a26e71e 100644 --- a/lib/mining/classifier/cart/cart.go +++ b/lib/mining/classifier/cart/cart.go @@ -1,6 +1,6 @@ -// Copyright 2015 Mhd Sulhan <ms@kilabit.info>. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. +// SPDX-FileCopyrightText: 2015 M. Shulhan <ms@kilabit.info> +// +// SPDX-License-Identifier: BSD-3-Clause // Package cart implement the Classification and Regression Tree by Breiman, et al. // CART is binary decision tree. @@ -155,7 +155,7 @@ func (runtime *Runtime) splitTreeByGain(claset tabula.ClasetInterface) ( // If its continuous, split the attribute using numeric value. // If its discrete, split the attribute using subset (partition) of // nominal values. - var splitV interface{} + var splitV any if MaxGain.IsContinu { splitV = MaxGain.GetMaxPartGainValue() diff --git a/lib/mining/classifier/cart/node.go b/lib/mining/classifier/cart/node.go index 0317704d..3e95cc04 100644 --- a/lib/mining/classifier/cart/node.go +++ b/lib/mining/classifier/cart/node.go @@ -1,6 +1,6 @@ -// Copyright 2015 Mhd Sulhan <ms@kilabit.info>. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. +// SPDX-FileCopyrightText: 2015 M. Shulhan <ms@kilabit.info> +// +// SPDX-License-Identifier: BSD-3-Clause package cart @@ -12,7 +12,7 @@ import ( // NodeValue of tree in CART. type NodeValue struct { // SplitV define the split value. - SplitV interface{} + SplitV any // Class of leaf node. Class string diff --git a/lib/mining/gain/gini/gini.go b/lib/mining/gain/gini/gini.go index 58c7fd5a..f9b61e4b 100644 --- a/lib/mining/gain/gini/gini.go +++ b/lib/mining/gain/gini/gini.go @@ -1,6 +1,6 @@ -// Copyright 2015 Mhd Sulhan <ms@kilabit.info>. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. +// SPDX-FileCopyrightText: 2015 M. Shulhan <ms@kilabit.info> +// +// SPDX-License-Identifier: BSD-3-Clause // Package gini contain function to calculating Gini gain. // @@ -307,7 +307,7 @@ func (gini *Gini) computeContinuGain(src *[]float64, target, classes *[]string) } // GetMaxPartGainValue return the partition that have the maximum Gini gain. -func (gini *Gini) GetMaxPartGainValue() interface{} { +func (gini *Gini) GetMaxPartGainValue() any { if gini.IsContinu { return gini.ContinuPart[gini.MaxPartGain] } @@ -322,7 +322,7 @@ func (gini *Gini) GetMaxGainValue() float64 { } // GetMinIndexPartValue return the partition that have the minimum Gini index. -func (gini *Gini) GetMinIndexPartValue() interface{} { +func (gini *Gini) GetMinIndexPartValue() any { if gini.IsContinu { return gini.ContinuPart[gini.MinIndexPart] } diff --git a/lib/mining/tree/binary/btnode.go b/lib/mining/tree/binary/btnode.go index ad8c0876..d8b78b92 100644 --- a/lib/mining/tree/binary/btnode.go +++ b/lib/mining/tree/binary/btnode.go @@ -1,6 +1,6 @@ -// Copyright 2015 Mhd Sulhan <ms@kilabit.info>. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. +// SPDX-FileCopyrightText: 2015 M. Shulhan <ms@kilabit.info> +// +// SPDX-License-Identifier: BSD-3-Clause package binary @@ -18,11 +18,11 @@ type BTNode struct { // Parent of node. Parent *BTNode // Value of node. - Value interface{} + Value any } // NewBTNode create new node for binary tree. -func NewBTNode(v interface{}, l *BTNode, r *BTNode) (p *BTNode) { +func NewBTNode(v any, l *BTNode, r *BTNode) (p *BTNode) { p = &BTNode{ Left: l, Right: r, diff --git a/lib/mlog/mlog.go b/lib/mlog/mlog.go index 155a2500..a22867c2 100644 --- a/lib/mlog/mlog.go +++ b/lib/mlog/mlog.go @@ -1,6 +1,6 @@ -// Copyright 2021, Shulhan <ms@kilabit.info>. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. +// SPDX-FileCopyrightText: 2021 M. Shulhan <ms@kilabit.info> +// +// SPDX-License-Identifier: BSD-3-Clause // Package mlog implement buffered multi writers of log. // It can have zero or more normal writers (for example, os.Stdout and @@ -49,12 +49,12 @@ var defaultMLog = createMultiLogger(defTimeFormat, ``, // The default registered error writer is os.Stderr. // // If the generated string does not end with new line, it will be added. -func Errf(format string, v ...interface{}) { +func Errf(format string, v ...any) { defaultMLog.Errf(format, v...) } // Fatalf is equal to Errf and os.Exit(1). -func Fatalf(format string, v ...interface{}) { +func Fatalf(format string, v ...any) { defaultMLog.Fatalf(format, v...) } @@ -67,12 +67,12 @@ func Flush() { // The default registered output writer is os.Stdout. // // If the generated string does not end with new line, it will be added. -func Outf(format string, v ...interface{}) { +func Outf(format string, v ...any) { defaultMLog.Outf(format, v...) } // Panicf is equal to Errf followed by panic. -func Panicf(format string, v ...interface{}) { +func Panicf(format string, v ...any) { defaultMLog.Panicf(format, v...) } diff --git a/lib/mlog/multi_logger.go b/lib/mlog/multi_logger.go index bf8c3b87..899bc304 100644 --- a/lib/mlog/multi_logger.go +++ b/lib/mlog/multi_logger.go @@ -56,7 +56,7 @@ func createMultiLogger(timeFormat, prefix string, outs, errs []NamedWriter) (mlo mlog = &MultiLogger{ bufPool: &sync.Pool{ - New: func() interface{} { + New: func() any { return new(bytes.Buffer) }, }, @@ -124,12 +124,12 @@ func (mlog *MultiLogger) Close() { // writers. // // If the generated string does not end with new line, it will be added. -func (mlog *MultiLogger) Errf(format string, v ...interface{}) { +func (mlog *MultiLogger) Errf(format string, v ...any) { mlog.writeTo(mlog.qerr, format, v...) } // Fatalf is equal to Errf and os.Exit(1). -func (mlog *MultiLogger) Fatalf(format string, v ...interface{}) { +func (mlog *MultiLogger) Fatalf(format string, v ...any) { mlog.Errf(format, v...) mlog.Flush() os.Exit(1) @@ -152,12 +152,12 @@ func (mlog *MultiLogger) Flush() { // Outf write the formatted string and its values to all output writers. // // If the generated string does not end with new line, it will be added. -func (mlog *MultiLogger) Outf(format string, v ...interface{}) { +func (mlog *MultiLogger) Outf(format string, v ...any) { mlog.writeTo(mlog.qout, format, v...) } // Panicf is equal to Errf and followed by panic. -func (mlog *MultiLogger) Panicf(format string, v ...interface{}) { +func (mlog *MultiLogger) Panicf(format string, v ...any) { mlog.Errf(format, v...) mlog.Flush() var msg = fmt.Sprintf(format, v...) @@ -288,7 +288,7 @@ func (mlog *MultiLogger) processOutputQueue() { mlog.flushq <- struct{}{} } -func (mlog *MultiLogger) writeTo(q chan []byte, format string, v ...interface{}) { +func (mlog *MultiLogger) writeTo(q chan []byte, format string, v ...any) { mlog.Lock() if mlog.isClosed { mlog.Unlock() diff --git a/lib/paseto/example_public_mode_test.go b/lib/paseto/example_public_mode_test.go index 6e076b69..a821c93b 100644 --- a/lib/paseto/example_public_mode_test.go +++ b/lib/paseto/example_public_mode_test.go @@ -1,6 +1,6 @@ -// Copyright 2020, Shulhan <ms@kilabit.info>. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. +// SPDX-FileCopyrightText: 2020 M. Shulhan <ms@kilabit.info> +// +// SPDX-License-Identifier: BSD-3-Clause package paseto @@ -47,7 +47,7 @@ func ExamplePublicMode() { log.Fatal(err) } - footer := map[string]interface{}{ + footer := map[string]any{ "FOOTER": "HERE", } token, err := sender.Pack(receiverKey.ID, subjectMessage, []byte("hello receiver"), footer) diff --git a/lib/paseto/json_footer.go b/lib/paseto/json_footer.go index fe037ffb..990ee688 100644 --- a/lib/paseto/json_footer.go +++ b/lib/paseto/json_footer.go @@ -1,12 +1,12 @@ -// Copyright 2020, Shulhan <ms@kilabit.info>. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. +// SPDX-FileCopyrightText: 2020 M. Shulhan <ms@kilabit.info> +// +// SPDX-License-Identifier: BSD-3-Clause package paseto // JSONFooter define the optional metadata and data at the footer of the // token that are not included in signature. type JSONFooter struct { - Data map[string]interface{} `json:"data,omitempty"` - KID string `json:"kid"` + Data map[string]any `json:"data,omitempty"` + KID string `json:"kid"` } diff --git a/lib/paseto/public_mode.go b/lib/paseto/public_mode.go index 46177ba7..b43b56d3 100644 --- a/lib/paseto/public_mode.go +++ b/lib/paseto/public_mode.go @@ -1,6 +1,6 @@ -// Copyright 2020, Shulhan <ms@kilabit.info>. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. +// SPDX-FileCopyrightText: 2020 M. Shulhan <ms@kilabit.info> +// +// SPDX-License-Identifier: BSD-3-Clause package paseto @@ -106,7 +106,7 @@ func (auth *PublicMode) RemovePeer(id string) { } // Pack the data into token. -func (auth *PublicMode) Pack(audience, subject string, data []byte, footer map[string]interface{}) ( +func (auth *PublicMode) Pack(audience, subject string, data []byte, footer map[string]any) ( token string, err error, ) { now := time.Now().Round(time.Second) diff --git a/lib/reflect/example_test.go b/lib/reflect/example_test.go index f69c45d1..c0b028a3 100644 --- a/lib/reflect/example_test.go +++ b/lib/reflect/example_test.go @@ -1,6 +1,6 @@ -// Copyright 2020, Shulhan <ms@kilabit.info>. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. +// SPDX-FileCopyrightText: 2020 M. Shulhan <ms@kilabit.info> +// +// SPDX-License-Identifier: BSD-3-Clause package reflect_test @@ -82,9 +82,9 @@ func ExampleIsNil() { ) cases := []struct { - v interface{} + v any }{ - {}, // Uninitialized interface{}. + {}, // Uninitialized any. {v: aBoolean}, {v: aChannel}, // Uninitialized channel. {v: aFunction}, // Empty func type. @@ -97,7 +97,7 @@ func ExampleIsNil() { {v: anInt}, {v: emptyError}, {v: errors.New("e")}, // Initialized error. - {v: fs}, // Uninitialized interface type to interface{}. + {v: fs}, // Uninitialized interface type to any. } for _, c := range cases { diff --git a/lib/reflect/reflect.go b/lib/reflect/reflect.go index f5f917f5..c3ff568c 100644 --- a/lib/reflect/reflect.go +++ b/lib/reflect/reflect.go @@ -23,7 +23,7 @@ const ( // [Equal] method in that struct to compare the values. // A struct's field tagged with `noequal:""` will be skipped from being // processed. -func DoEqual(x, y interface{}) (err error) { +func DoEqual(x, y any) (err error) { if x == nil && y == nil { return nil } @@ -45,7 +45,7 @@ func DoEqual(x, y interface{}) (err error) { // [Equal] method in that struct to compare the values. // A struct's field tagged with `noequal:""` will be skipped from being // processed. -func IsEqual(x, y interface{}) bool { +func IsEqual(x, y any) bool { if x == nil && y == nil { return true } @@ -60,7 +60,7 @@ func IsEqual(x, y interface{}) bool { // IsNil will return true if v's type is chan, func, interface, map, pointer, // or slice and its value is `nil`; otherwise it will return false. -func IsNil(v interface{}) bool { +func IsNil(v any) bool { var val = reflect.ValueOf(v) var kind = val.Kind() @@ -86,7 +86,7 @@ func IsNil(v interface{}) bool { // // If obj is nil or none of the method exist it will return nil without an // error. -func Marshal(obj interface{}) (out []byte, err error) { +func Marshal(obj any) (out []byte, err error) { var ( logp = "Marshal" methodNames = []string{ @@ -100,7 +100,7 @@ func Marshal(obj interface{}) (out []byte, err error) { methodName string method reflect.Value callOut []reflect.Value - callReturn interface{} + callReturn any ok bool ) @@ -285,7 +285,7 @@ func setValue(obj reflect.Value, val string) (err error) { objKind = obj.Kind() objValue reflect.Value - v interface{} + v any ) for objKind == reflect.Ptr { @@ -438,7 +438,7 @@ func Unmarshal(obj reflect.Value, val []byte) (ok bool, err error) { objValue reflect.Value method reflect.Value callOut []reflect.Value - callReturn interface{} + callReturn any methodName string ) @@ -550,12 +550,12 @@ func Tag(field reflect.StructField, tag string) (val string, opts []string, hasT // doEqual compare two kind of objects and return nils if both are equal. // -// If its not equal, it will return the interface{} value of v1 and v2 and +// If its not equal, it will return the any value of v1 and v2 and // additional error message which describe the type and value where its not // matched. func doEqual(v1, v2 reflect.Value) (err error) { var ( - in1, in2 interface{} + in1, in2 any ) if !v1.IsValid() || !v2.IsValid() { diff --git a/lib/reflect/reflect_test.go b/lib/reflect/reflect_test.go index 7f839ed6..5243d733 100644 --- a/lib/reflect/reflect_test.go +++ b/lib/reflect/reflect_test.go @@ -1,6 +1,6 @@ -// Copyright 2022, Shulhan <ms@kilabit.info>. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. +// SPDX-FileCopyrightText: 2022 M. Shulhan <ms@kilabit.info> +// +// SPDX-License-Identifier: BSD-3-Clause package reflect @@ -23,8 +23,8 @@ func TestAppendSlice(t *testing.T) { ) type testCase struct { - obj interface{} - exp interface{} + obj any + exp any desc string vals []string } diff --git a/lib/sql/session.go b/lib/sql/session.go index fc1c5c1e..62650410 100644 --- a/lib/sql/session.go +++ b/lib/sql/session.go @@ -1,6 +1,6 @@ -// Copyright 2020, Shulhan <ms@kilabit.info>. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. +// SPDX-FileCopyrightText: 2020 M. Shulhan <ms@kilabit.info> +// +// SPDX-License-Identifier: BSD-3-Clause package sql @@ -11,12 +11,12 @@ import ( // Session is an interface that represent both sql.DB and sql.Tx. type Session interface { - Exec(query string, args ...interface{}) (sql.Result, error) - ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error) + Exec(query string, args ...any) (sql.Result, error) + ExecContext(ctx context.Context, query string, args ...any) (sql.Result, error) Prepare(query string) (*sql.Stmt, error) PrepareContext(ctx context.Context, query string) (*sql.Stmt, error) - Query(query string, args ...interface{}) (*sql.Rows, error) - QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error) - QueryRow(query string, args ...interface{}) *sql.Row - QueryRowContext(ctx context.Context, query string, args ...interface{}) *sql.Row + Query(query string, args ...any) (*sql.Rows, error) + QueryContext(ctx context.Context, query string, args ...any) (*sql.Rows, error) + QueryRow(query string, args ...any) *sql.Row + QueryRowContext(ctx context.Context, query string, args ...any) *sql.Row } diff --git a/lib/ssh/sftp/file_attrs.go b/lib/ssh/sftp/file_attrs.go index 87ffc763..a4a8995d 100644 --- a/lib/ssh/sftp/file_attrs.go +++ b/lib/ssh/sftp/file_attrs.go @@ -1,6 +1,6 @@ -// Copyright 2021, Shulhan <ms@kilabit.info>. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. +// SPDX-FileCopyrightText: 2021 M. Shulhan <ms@kilabit.info> +// +// SPDX-License-Identifier: BSD-3-Clause package sftp @@ -258,7 +258,7 @@ func (fa *FileAttrs) Size() int64 { // Sys return the pointer to [FileAttrs] itself. // This method is added to comply with [fs.FileInfo] interface. -func (fa *FileAttrs) Sys() interface{} { +func (fa *FileAttrs) Sys() any { return fa } diff --git a/lib/strings/to.go b/lib/strings/to.go index cc8649ef..6b46a724 100644 --- a/lib/strings/to.go +++ b/lib/strings/to.go @@ -1,6 +1,6 @@ -// Copyright 2018, Shulhan <ms@kilabit.info>. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. +// SPDX-FileCopyrightText: 2018 M. Shulhan <ms@kilabit.info> +// +// SPDX-License-Identifier: BSD-3-Clause package strings @@ -63,7 +63,7 @@ func ToInt64(ss []string) (sv []int64) { } // ToStrings convert slice of interface to slice of string. -func ToStrings(is []interface{}) (vs []string) { +func ToStrings(is []any) (vs []string) { for x := 0; x < len(is); x++ { v := fmt.Sprintf("%v", is[x]) vs = append(vs, v) diff --git a/lib/strings/to_example_test.go b/lib/strings/to_example_test.go index 59dc8db7..52a430e7 100644 --- a/lib/strings/to_example_test.go +++ b/lib/strings/to_example_test.go @@ -1,6 +1,6 @@ -// Copyright 2018, Shulhan <ms@kilabit.info>. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. +// SPDX-FileCopyrightText: 2018 M. Shulhan <ms@kilabit.info> +// +// SPDX-License-Identifier: BSD-3-Clause package strings @@ -40,7 +40,7 @@ func ExampleToInt64() { func ExampleToStrings() { var ( - i64 = []interface{}{0, 1.99, 2, 3} + i64 = []any{0, 1.99, 2, 3} ss = ToStrings(i64) ) diff --git a/lib/strings/to_test.go b/lib/strings/to_test.go index 18d971c1..11a674e0 100644 --- a/lib/strings/to_test.go +++ b/lib/strings/to_test.go @@ -1,6 +1,6 @@ -// Copyright 2018, Shulhan <ms@kilabit.info>. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. +// SPDX-FileCopyrightText: 2018 M. Shulhan <ms@kilabit.info> +// +// SPDX-License-Identifier: BSD-3-Clause package strings @@ -32,7 +32,7 @@ func TestToInt64(t *testing.T) { func TestToStrings(t *testing.T) { var ( - is = make([]interface{}, 0) + is = make([]any, 0) i64 = []int64{0, 1, 2, 3} exp = []string{`0`, `1`, `2`, `3`} diff --git a/lib/tabula/claset.go b/lib/tabula/claset.go index 4ea7b1f3..cc51f017 100644 --- a/lib/tabula/claset.go +++ b/lib/tabula/claset.go @@ -1,6 +1,6 @@ -// Copyright 2017, Shulhan <ms@kilabit.info>. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be found -// in the LICENSE file. +// SPDX-FileCopyrightText: 2017 M. Shulhan <ms@kilabit.info> +// +// SPDX-License-Identifier: BSD-3-Clause package tabula @@ -45,7 +45,7 @@ func NewClaset(mode int, types []int, names []string) (claset *Claset) { } // Clone return a copy of current claset object. -func (claset *Claset) Clone() interface{} { +func (claset *Claset) Clone() any { clone := Claset{ ClassIndex: claset.GetClassIndex(), major: claset.MajorityClass(), diff --git a/lib/tabula/column.go b/lib/tabula/column.go index 091d6ad5..d7d85483 100644 --- a/lib/tabula/column.go +++ b/lib/tabula/column.go @@ -1,6 +1,6 @@ -// Copyright 2017, Shulhan <ms@kilabit.info>. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be found -// in the LICENSE file. +// SPDX-FileCopyrightText: 2017 M. Shulhan <ms@kilabit.info> +// +// SPDX-License-Identifier: BSD-3-Clause package tabula @@ -126,7 +126,7 @@ func (col *Column) SetRecords(recs *Records) { } // Interface return the column object as an interface. -func (col *Column) Interface() interface{} { +func (col *Column) Interface() any { return col } diff --git a/lib/tabula/columninterface.go b/lib/tabula/columninterface.go index d5bb8dd3..02d9a2ce 100644 --- a/lib/tabula/columninterface.go +++ b/lib/tabula/columninterface.go @@ -1,6 +1,6 @@ -// Copyright 2017, Shulhan <ms@kilabit.info>. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be found -// in the LICENSE file. +// SPDX-FileCopyrightText: 2017 M. Shulhan <ms@kilabit.info> +// +// SPDX-License-Identifier: BSD-3-Clause package tabula @@ -14,5 +14,5 @@ type ColumnInterface interface { SetRecords(recs *Records) - Interface() interface{} + Interface() any } diff --git a/lib/tabula/dataset.go b/lib/tabula/dataset.go index dfcc11be..e6e87b3b 100644 --- a/lib/tabula/dataset.go +++ b/lib/tabula/dataset.go @@ -1,6 +1,6 @@ -// Copyright 2017, Shulhan <ms@kilabit.info>. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be found -// in the LICENSE file. +// SPDX-FileCopyrightText: 2017 M. Shulhan <ms@kilabit.info> +// +// SPDX-License-Identifier: BSD-3-Clause package tabula @@ -68,7 +68,7 @@ func (dataset *Dataset) Init(mode int, types []int, names []string) { } // Clone return a copy of current dataset. -func (dataset *Dataset) Clone() interface{} { +func (dataset *Dataset) Clone() any { clone := NewDataset(dataset.GetMode(), nil, nil) for _, col := range dataset.Columns { @@ -299,7 +299,7 @@ func (dataset *Dataset) SetRows(rows *Rows) { } // GetData return the data, based on mode (rows, columns, or matrix). -func (dataset *Dataset) GetData() interface{} { +func (dataset *Dataset) GetData() any { switch dataset.Mode { case DatasetModeRows: return &dataset.Rows diff --git a/lib/tabula/datasetinterface.go b/lib/tabula/datasetinterface.go index 18557bba..d695fbc2 100644 --- a/lib/tabula/datasetinterface.go +++ b/lib/tabula/datasetinterface.go @@ -1,6 +1,6 @@ -// Copyright 2017, Shulhan <ms@kilabit.info>. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be found -// in the LICENSE file. +// SPDX-FileCopyrightText: 2017 M. Shulhan <ms@kilabit.info> +// +// SPDX-License-Identifier: BSD-3-Clause package tabula @@ -12,7 +12,7 @@ import ( // DatasetInterface is the interface for working with DSV data. type DatasetInterface interface { Init(mode int, types []int, names []string) - Clone() interface{} + Clone() any Reset() error GetMode() int @@ -42,7 +42,7 @@ type DatasetInterface interface { SetRows(*Rows) DeleteRow(idx int) *Row - GetData() interface{} + GetData() any GetDataAsRows() *Rows GetDataAsColumns() *Columns @@ -61,7 +61,7 @@ type DatasetInterface interface { // ReadDatasetConfig open dataset configuration file and initialize dataset // field from there. -func ReadDatasetConfig(ds interface{}, fcfg string) (e error) { +func ReadDatasetConfig(ds any, fcfg string) (e error) { cfg, e := os.ReadFile(fcfg) if nil != e { @@ -221,7 +221,7 @@ func SplitRowsByCategorical(di DatasetInterface, colidx int, splitVal []string) // split data using value in column `colidx`. If value is numeric it will return // any rows that have column value less than `value` in `splitL`, and any column // value greater or equal to `value` in `splitR`. -func SplitRowsByValue(di DatasetInterface, colidx int, value interface{}) ( +func SplitRowsByValue(di DatasetInterface, colidx int, value any) ( splitL DatasetInterface, splitR DatasetInterface, e error, diff --git a/lib/tabula/record.go b/lib/tabula/record.go index 63a24a58..1d108e14 100644 --- a/lib/tabula/record.go +++ b/lib/tabula/record.go @@ -1,6 +1,6 @@ -// Copyright 2017, Shulhan <ms@kilabit.info>. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be found -// in the LICENSE file. +// SPDX-FileCopyrightText: 2017 M. Shulhan <ms@kilabit.info> +// +// SPDX-License-Identifier: BSD-3-Clause package tabula @@ -23,7 +23,7 @@ const ( // Record represent the smallest building block of data-set. type Record struct { - v interface{} + v any } // NewRecord will create and return record with nil value. @@ -143,7 +143,7 @@ func (r *Record) IsMissingValue() bool { } // Interface return record value as interface. -func (r *Record) Interface() interface{} { +func (r *Record) Interface() any { return r.v } @@ -226,7 +226,7 @@ func (r *Record) IsEqualToString(v string) bool { // IsEqualToInterface return true if interface type and value equal to record // type and value. -func (r *Record) IsEqualToInterface(v interface{}) bool { +func (r *Record) IsEqualToInterface(v any) bool { return reflect.DeepEqual(r.v, v) } diff --git a/lib/tabula/records.go b/lib/tabula/records.go index 592f1699..e6a4ca9d 100644 --- a/lib/tabula/records.go +++ b/lib/tabula/records.go @@ -1,6 +1,6 @@ -// Copyright 2017, Shulhan <ms@kilabit.info>. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be found -// in the LICENSE file. +// SPDX-FileCopyrightText: 2017 M. Shulhan <ms@kilabit.info> +// +// SPDX-License-Identifier: BSD-3-Clause package tabula @@ -25,7 +25,7 @@ func (recs *Records) SortByIndex(sortedIdx []int) *Records { // CountWhere return number of record where its value is equal to `v` type and // value. -func (recs *Records) CountWhere(v interface{}) (c int) { +func (recs *Records) CountWhere(v any) (c int) { for _, r := range *recs { if r.IsEqualToInterface(v) { c++ @@ -35,7 +35,7 @@ func (recs *Records) CountWhere(v interface{}) (c int) { } // CountsWhere will return count of each value in slice `sv`. -func (recs *Records) CountsWhere(vs []interface{}) (counts []int) { +func (recs *Records) CountsWhere(vs []any) (counts []int) { for _, v := range vs { c := recs.CountWhere(v) counts = append(counts, c) diff --git a/lib/tabula/row.go b/lib/tabula/row.go index 99c96d7e..1e08e6fe 100644 --- a/lib/tabula/row.go +++ b/lib/tabula/row.go @@ -1,6 +1,6 @@ -// Copyright 2017, Shulhan <ms@kilabit.info>. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be found -// in the LICENSE file. +// SPDX-FileCopyrightText: 2017 M. Shulhan <ms@kilabit.info> +// +// SPDX-License-Identifier: BSD-3-Clause package tabula @@ -69,7 +69,7 @@ func (row *Row) GetRecord(i int) *Record { // GetValueAt return the value of row record at index `idx`. If the index is // out of range it will return nil and false -func (row *Row) GetValueAt(idx int) (interface{}, bool) { +func (row *Row) GetValueAt(idx int) (any, bool) { if row.Len() <= idx { return nil, false } diff --git a/lib/test/test.go b/lib/test/test.go index 5a85f58a..66419a5b 100644 --- a/lib/test/test.go +++ b/lib/test/test.go @@ -56,7 +56,7 @@ import ( // // LIMITATION: this method does not support recursive pointer, for example a // node that point to parent and parent that point back to node again. -func Assert(w Writer, name string, exp, got interface{}) { +func Assert(w Writer, name string, exp, got any) { w.Helper() var logp = `Assert` @@ -78,7 +78,7 @@ func Assert(w Writer, name string, exp, got interface{}) { } } -func printStringDiff(w Writer, name string, exp, got interface{}) bool { +func printStringDiff(w Writer, name string, exp, got any) bool { var ( diffData diff.Data expStr string diff --git a/lib/test/test_test.go b/lib/test/test_test.go index 3fb4bdd0..90a5fa91 100644 --- a/lib/test/test_test.go +++ b/lib/test/test_test.go @@ -1,6 +1,6 @@ -// Copyright 2018, Shulhan <ms@kilabit.info>. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. +// SPDX-FileCopyrightText: 2018 M. Shulhan <ms@kilabit.info> +// +// SPDX-License-Identifier: BSD-3-Clause package test @@ -10,8 +10,8 @@ import ( func TestAssert(t *testing.T) { type testCase struct { - a interface{} - b interface{} + a any + b any exp string desc string } @@ -19,7 +19,7 @@ func TestAssert(t *testing.T) { var str = `a string` var cases = []testCase{{ - desc: `nil interface{}`, + desc: `nil any`, a: nil, b: &str, exp: `!!! Assert: IsValid: expecting <invalid Value>(false), got <*string Value>(true)`, diff --git a/lib/websocket/clientmanager.go b/lib/websocket/clientmanager.go index 7c1ad61e..87f97465 100644 --- a/lib/websocket/clientmanager.go +++ b/lib/websocket/clientmanager.go @@ -1,6 +1,6 @@ -// Copyright 2018, Shulhan <ms@kilabit.info>. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. +// SPDX-FileCopyrightText: 2018 M. Shulhan <ms@kilabit.info> +// +// SPDX-License-Identifier: BSD-3-Clause package websocket @@ -158,7 +158,7 @@ func (cls *ClientManager) setFrames(conn int, frames *Frames) { // add new socket connection to user ID in context. func (cls *ClientManager) add(ctx context.Context, conn int) { var ( - v interface{} + v any uid uint64 conns []int ok bool @@ -195,7 +195,7 @@ func (cls *ClientManager) add(ctx context.Context, conn int) { func (cls *ClientManager) remove(conn int) { var ( ctx context.Context - v interface{} + v any conns []int ok bool ) diff --git a/lib/websocket/handshake.go b/lib/websocket/handshake.go index 122baa46..57fd0e11 100644 --- a/lib/websocket/handshake.go +++ b/lib/websocket/handshake.go @@ -1,6 +1,6 @@ -// Copyright 2018, Shulhan <ms@kilabit.info>. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. +// SPDX-FileCopyrightText: 2018 M. Shulhan <ms@kilabit.info> +// +// SPDX-License-Identifier: BSD-3-Clause package websocket @@ -63,7 +63,7 @@ const ( var ( _handshakePool = sync.Pool{ - New: func() interface{} { + New: func() any { return new(Handshake) }, } diff --git a/lib/websocket/request.go b/lib/websocket/request.go index 60a44349..ad7bcb53 100644 --- a/lib/websocket/request.go +++ b/lib/websocket/request.go @@ -1,6 +1,6 @@ -// Copyright 2018, Shulhan <ms@kilabit.info>. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. +// SPDX-FileCopyrightText: 2018 M. Shulhan <ms@kilabit.info> +// +// SPDX-License-Identifier: BSD-3-Clause package websocket @@ -13,7 +13,7 @@ import ( var ( _reqPool = sync.Pool{ - New: func() interface{} { + New: func() any { return new(Request) }, } diff --git a/lib/websocket/response.go b/lib/websocket/response.go index 6ea65b24..48bcb020 100644 --- a/lib/websocket/response.go +++ b/lib/websocket/response.go @@ -1,6 +1,6 @@ -// Copyright 2018, Shulhan <ms@kilabit.info>. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. +// SPDX-FileCopyrightText: 2018 M. Shulhan <ms@kilabit.info> +// +// SPDX-License-Identifier: BSD-3-Clause package websocket @@ -12,7 +12,7 @@ import ( var ( _resPool = sync.Pool{ - New: func() interface{} { + New: func() any { return new(Response) }, } diff --git a/lib/websocket/websocket.go b/lib/websocket/websocket.go index e0e80927..9e6e994b 100644 --- a/lib/websocket/websocket.go +++ b/lib/websocket/websocket.go @@ -1,6 +1,6 @@ -// Copyright 2018, Shulhan <ms@kilabit.info>. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. +// SPDX-FileCopyrightText: 2018 M. Shulhan <ms@kilabit.info> +// +// SPDX-License-Identifier: BSD-3-Clause package websocket @@ -28,7 +28,7 @@ var ( defaultPingInterval = 10 * time.Second _bbPool = sync.Pool{ - New: func() interface{} { + New: func() any { return new(bytes.Buffer) }, } diff --git a/lib/xmlrpc/request.go b/lib/xmlrpc/request.go index 0b9dce42..b388ae11 100644 --- a/lib/xmlrpc/request.go +++ b/lib/xmlrpc/request.go @@ -1,6 +1,6 @@ -// Copyright 2020, Shulhan <ms@kilabit.info>. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. +// SPDX-FileCopyrightText: 2020 M. Shulhan <ms@kilabit.info> +// +// SPDX-License-Identifier: BSD-3-Clause package xmlrpc @@ -18,7 +18,7 @@ type Request struct { } // NewRequest create and initialize new request. -func NewRequest(methodName string, params []interface{}) (req Request, err error) { +func NewRequest(methodName string, params []any) (req Request, err error) { req = Request{ MethodName: methodName, Params: make([]*Value, 0, len(params)), diff --git a/lib/xmlrpc/request_test.go b/lib/xmlrpc/request_test.go index 4f9b742d..d9d421f2 100644 --- a/lib/xmlrpc/request_test.go +++ b/lib/xmlrpc/request_test.go @@ -1,6 +1,6 @@ -// Copyright 2020, Shulhan <ms@kilabit.info>. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. +// SPDX-FileCopyrightText: 2020 M. Shulhan <ms@kilabit.info> +// +// SPDX-License-Identifier: BSD-3-Clause package xmlrpc @@ -18,17 +18,17 @@ type testStruct struct { func TestRequest_MarshalText(t *testing.T) { type testCase struct { methodName string - params []interface{} + params []any } var cases = []testCase{{ methodName: "method.name", - params: []interface{}{ + params: []any{ "param-string", }, }, { methodName: "test.struct", - params: []interface{}{ + params: []any{ testStruct{ X: 1, Y: true, @@ -36,7 +36,7 @@ func TestRequest_MarshalText(t *testing.T) { }, }, { methodName: "test.array", - params: []interface{}{ + params: []any{ []string{"a", "b"}, }, }} diff --git a/lib/xmlrpc/value.go b/lib/xmlrpc/value.go index c25ecd8d..00d6f010 100644 --- a/lib/xmlrpc/value.go +++ b/lib/xmlrpc/value.go @@ -1,6 +1,6 @@ -// Copyright 2020, Shulhan <ms@kilabit.info>. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. +// SPDX-FileCopyrightText: 2020 M. Shulhan <ms@kilabit.info> +// +// SPDX-License-Identifier: BSD-3-Clause package xmlrpc @@ -16,7 +16,7 @@ type Value struct { // In contains scalar value for Base64, Boolean, Double, Integer, // String, and DateTime. // It would be nil for Kind of Array and Struct. - In interface{} + In any // Pair of struct member name and its value. StructMembers map[string]*Value @@ -28,7 +28,7 @@ type Value struct { } // NewValue convert Go type data into XML-RPC value. -func NewValue(in interface{}) (out *Value) { +func NewValue(in any) (out *Value) { reft := reflect.TypeOf(in) if reft == nil { return nil |
