codec

package module
v0.0.0-...-0eef89e Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2025 License: MIT Imports: 4 Imported by: 1

README

go-codec

A lightweight Go package for base64 encoding/decoding and DEFLATE compression/decompression.

Installation

go get github.com/gokpm/go-codec

Usage

import (
    "compress/flate"
    "github.com/gokpm/go-codec"
    "log"
)

// Base64 operations
data := []byte("hello world")
encoded := codec.Encode(data)
decoded, err := codec.Decode(encoded)
if err != nil {
    log.Fatal(err)
}

// DEFLATE compression
compressed, err := codec.Compress(data, flate.DefaultCompression)
if err != nil {
    log.Fatal(err)
}
decompressed, err := codec.Decompress(compressed)
if err != nil {
    log.Fatal(err)
}

Functions

  • Encode(input []byte) string - Base64 encode bytes to string
  • Decode(input string) ([]byte, error) - Base64 decode string to bytes
  • Compress(input []byte, level int) ([]byte, error) - DEFLATE compress bytes
  • Decompress(input []byte) ([]byte, error) - DEFLATE decompress bytes

License

MIT

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Compress

func Compress(input []byte, level int) ([]byte, error)

Compress compresses byte slice using DEFLATE algorithm with specified compression level level: compression level (flate.NoCompression, flate.BestSpeed, flate.BestCompression, flate.DefaultCompression)

func Decode

func Decode(input string) ([]byte, error)

Decode converts base64 encoded string back to byte slice

func Decompress

func Decompress(input []byte) ([]byte, error)

Decompress decompresses DEFLATE compressed byte slice back to original data

func Encode

func Encode(input []byte) string

Encode converts byte slice to base64 encoded string

Types

This section is empty.

Jump to

Keyboard shortcuts

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