package
1.5.0
Repository: https://github.com/cognusion/go-jar.git
Documentation: pkg.go.dev

# README

dictionary

import "github.com/cognusion/go-jar/dictionary"

Overview

Package dictionary provides the Dictionary interface for abstraction, and a simple stringmap implementation called SimpleDict, used for macro definition and replacement. Dictionary is an abstraction from JAR.

Index

Package files

dict.go simpledict.go syncdict.go

type Dictionary

type Dictionary interface {
    // Replacer takes a string, and expands any %%-prefixed strings registered as macros, with their corresponding values
    Replacer(string) string
}

Dictionary is an interface for macro-expanding structures

type Resolver

type Resolver interface {
    // Replacer takes a string, and expands any %%-prefixed strings registered as macros, with their corresponding values
    Replacer(string) string
    // Resolve is intended to walk the dictionary and replace any dictionary items with static strings
    Resolve()
}

Resolver is an interface for macro-expanded structures that also can replace their own embedded macros with static strings

type SimpleDict

type SimpleDict map[string]string

SimpleDict is a string map Dictionary to do simple key-value replacements

func (*SimpleDict) Replacer

func (m *SimpleDict) Replacer(in string) string

Replacer takes a string, and expands any %%-prefixed strings registered as macros, with their corresponding values. Note that shortest-prefixes may match first, so for dictionaries of %%VERSION1="one" and %%VERSION12="twelve" you may find cases where %%VERSION12 is expanded to "twelve" or "one2". WONTFIX

func (*SimpleDict) Resolve

func (m *SimpleDict) Resolve()

Resolve walks the dictionary and updates any values that contain macros with static strings.

type SyncDict

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

SyncDict is a string map Dictionary to do simple key-value replacements. It is goro-safe for updates, and optimized for read-mostly implementations.

func (*SyncDict) AddValues

func (m *SyncDict) AddValues(values map[string]string)

AddValues adds the key/value pairs listed to the the SyncDict

func (*SyncDict) Replacer

func (m *SyncDict) Replacer(in string) string

Replacer takes a string, and expands any %%-prefixed strings registered as macros, with their corresponding values

func (*SyncDict) Resolve

func (m *SyncDict) Resolve()

Resolve walks the dictionary and updates any values that contain macros with static strings.


Generated by godoc2md