Help us shape the future of Go! Take the 2026 Go Developer Survey

sourcemark

package
v0.62.0 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package sourcemark stores a source node's custom feed mark as a normalized square PNG under the app data dir, content-addressed by hash. A node's config records the hash; a missing file falls back to the node's glyph. See ADR webhook-source-image-marks.

Index

Constants

View Source
const (
	// MaxInputBytes caps a raw upload before decoding.
	MaxInputBytes = 8 << 20

	// HashLen is the character length of a mark reference: hex of the first 16
	// bytes of the stored PNG's SHA-256.
	HashLen = 32
)

Variables

View Source
var (
	ErrEmpty       = errors.New("sourcemark: image is empty")
	ErrTooLarge    = errors.New("sourcemark: image is too large")
	ErrUnsupported = errors.New("sourcemark: unsupported image format")
)

Functions

func ValidHash

func ValidHash(s string) bool

ValidHash reports whether s is lowercase hex of length HashLen — the shape Set produces. It also guards Get against path traversal.

Types

type Store

type Store struct {
	// contains filtered or unexported fields
}

Store keeps normalized mark PNGs under dir, one per content hash.

func NewStore

func NewStore(dir string) *Store

NewStore returns a store rooted at dir. The directory is created on first write.

func (*Store) Get

func (s *Store) Get(hash string) (data []byte, ok bool, err error)

Get returns the stored PNG for hash, or ok=false when none is stored. A malformed or missing hash reads as absent, not an error.

func (*Store) Set

func (s *Store) Set(raw []byte) (string, error)

Set normalizes raw into a square PNG, writes it as <hash>.png, and returns the content hash a node's config records.

Jump to

Keyboard shortcuts

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