maputil

package
v1.0.15 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 13, 2024 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

* Package maputil to provides utility api for map container

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddAll

func AddAll[E comparable, V any](mapa, mapb map[E]V) map[E]V

AddAll merge the target mapb into mapa

func Clear

func Clear[E comparable, V any](mapa map[E]V)

Clear remove all keys and values in map

func Clone

func Clone[E comparable, V any](mapa map[E]V) map[E]V

Clone copy all key and value to a new map

func JsonDecode added in v1.0.15

func JsonDecode[E comparable, V any](data []byte) (map[E]V, error)

JsonDecode 函数接受一个字节切片作为参数,用于解码JSON格式的数据, 并将解码后的结果存储在一个以E类型为键,V类型为值的map中返回。 如果解码失败,则返回error类型的错误信息。 其中,E类型需要是可比较的,V类型则没有限制。

func JsonEncode added in v1.0.15

func JsonEncode[E comparable, V any](mapa map[E]V) ([]byte, error)

JsonEncode 函数将一个类型为 map[E]V 的字典转换为 JSON 格式的字节数组 其中 E 必须是可比较的类型,V 可以是任意类型 参数 mapa 是待转换的字典 返回值为转换后的 JSON 格式的字节数组以及可能出现的错误

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL