codec

package
v2.26.3 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2024 License: MIT Imports: 0 Imported by: 0

README

Codec

Usage

package codec_test

import (
	"log"

	"github.com/go-kratos-ecosystem/components/v2/codec/json"
)

var j = json.Codec

func ExampleJSON() {
	bytes, err := j.Marshal(map[string]string{
		"key": "value",
	})
	if err != nil {
		log.Fatal(err)
	}

	var dest map[string]string
	err = j.Unmarshal(bytes, &dest)
	if err != nil {
		log.Fatal(err)
	}
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Codec

type Codec interface {
	// Marshal the given data into bytes.
	Marshal(data any) ([]byte, error)

	// Unmarshal the given bytes into dest.
	Unmarshal(src []byte, dest any) error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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