Documentation ¶
Overview ¶
license: https://mit-license.org * ============================================================================== * The MIT License (MIT) * * Copyright (c) 2020 Albert Moky * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. * ==============================================================================
license: https://mit-license.org * ============================================================================== * The MIT License (MIT) * * Copyright (c) 2020 Albert Moky * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. * ==============================================================================
license: https://mit-license.org * ============================================================================== * The MIT License (MIT) * * Copyright (c) 2020 Albert Moky * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. * ==============================================================================
license: https://mit-license.org * ============================================================================== * The MIT License (MIT) * * Copyright (c) 2021 Albert Moky * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. * ==============================================================================
license: https://mit-license.org * ============================================================================== * The MIT License (MIT) * * Copyright (c) 2020 Albert Moky * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. * ==============================================================================
license: https://mit-license.org * ============================================================================== * The MIT License (MIT) * * Copyright (c) 2020 Albert Moky * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. * ==============================================================================
Index ¶
- func Base58Decode(b58 string) []byte
- func Base58Encode(bytes []byte) string
- func Base58SetCoder(coder DataCoder)
- func Base64Decode(b64 string) []byte
- func Base64Encode(bytes []byte) string
- func Base64SetCoder(coder DataCoder)
- func HexDecode(h string) []byte
- func HexEncode(bytes []byte) string
- func HexSetCoder(coder DataCoder)
- func JSONDecode(string string) interface{}
- func JSONDecodeList(str string) []interface{}
- func JSONDecodeMap(str string) map[string]interface{}
- func JSONEncode(object interface{}) string
- func JSONEncodeList(array []interface{}) string
- func JSONEncodeMap(dict map[string]interface{}) string
- func JSONSetCoder(coder ObjectCoder)
- func UTF8Decode(bytes []byte) string
- func UTF8Encode(string string) []byte
- func UTF8SetCoder(coder StringCoder)
- type Base64Coder
- type DataCoder
- type HexCoder
- type ObjectCoder
- type StringCoder
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Base58Decode ¶
func Base58Encode ¶
func Base58SetCoder ¶
func Base58SetCoder(coder DataCoder)
func Base64Decode ¶
func Base64Encode ¶
func Base64SetCoder ¶
func Base64SetCoder(coder DataCoder)
func HexSetCoder ¶
func HexSetCoder(coder DataCoder)
func JSONDecode ¶
func JSONDecode(string string) interface{}
func JSONDecodeList ¶
func JSONDecodeList(str string) []interface{}
func JSONDecodeMap ¶
func JSONEncode ¶
func JSONEncode(object interface{}) string
func JSONEncodeList ¶
func JSONEncodeList(array []interface{}) string
func JSONEncodeMap ¶
func JSONSetCoder ¶
func JSONSetCoder(coder ObjectCoder)
func UTF8Decode ¶
func UTF8Encode ¶
func UTF8SetCoder ¶
func UTF8SetCoder(coder StringCoder)
Types ¶
type Base64Coder ¶
type Base64Coder struct{}
func (Base64Coder) Decode ¶
func (coder Base64Coder) Decode(string string) []byte
func (Base64Coder) Encode ¶
func (coder Base64Coder) Encode(data []byte) string
func (Base64Coder) Init ¶
func (coder Base64Coder) Init() DataCoder
type DataCoder ¶
type DataCoder interface { /** * Encode binary data to local string * * @param data - binary data * @return local string */ Encode(data []byte) string /** * Decode local string to binary data * * @param string - local string * @return binary data */ Decode(string string) []byte }
*
- Data Coder
- ~~~~~~~~~~
- Hex, Base58, Base64, ... *
- 1. encode binary data to string;
- 2. decode string to binary data.
type ObjectCoder ¶
type ObjectCoder interface { /** * Encode Map/List object to string * * @param object - Map or List * @return serialized string */ Encode(object interface{}) string /** * Decode string to Map/List object * * @param string - serialized string * @return Map or List */ Decode(string string) interface{} }
*
- Object Coder
- ~~~~~~~~~~~~
- JsON, XML, ... *
- 1. encode object to string;
- 2. decode string to object.
type StringCoder ¶
type StringCoder interface { /** * Encode local string to binary data * * @param string - local string * @return binary data */ Encode(string string) []byte /** * Decode binary data to local string * * @param bytes - binary data * @return local string */ Decode(bytes []byte) interface{} }
*
- String Coder
- ~~~~~~~~~~~~
- UTF-8, UTF-16, GBK, GB2312, ... *
- 1. encode string to binary data;
- 2. decode binary data to string.