s2m

package
v0.0.0-...-537076f Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2025 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package s2m 目的:go-redis库 HMSet 将一个 map[string]string 类型的值设置到redis, HGetAll 获取hash中的所有值返回 map[string]string 类型的数据, 此包主要用于简化使用以上两个函数的复杂性,将一个struct体写入到一个redis hash数据类型,或将HGetAll的返回值解析到redis

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MapToStruct

func MapToStruct(m map[string]string, out any) error

MapToStruct 将 map m(不是指针),转换为 struct, 并赋值到out(必须是指针),StructToMap的反函数

func StructToMap

func StructToMap(s any, out map[string]string) error

StructToMap 将 struct s(可以是指针也可以不是指针),转换为 map[string]string, 并赋值到out(不是指针),MapToStruct的反函数

Types

type StringToType

type StringToType interface {
	// StringToTypeS2m 这个要实现指针方法不然无法赋值
	StringToTypeS2m([]byte) error
}

StringToType 解码

type TypeToString

type TypeToString interface {
	// TypeToStringS2m 指针非指针方法都行
	TypeToStringS2m() ([]byte, error)
}

TypeToString 编码

Jump to

Keyboard shortcuts

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