properties

package
v4.0.0-...-5d6a4c2 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package properties is used to read or write or modify the properties document.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Save

func Save(doc *Document, writer io.Writer) error

Save is used to save the doc to file or stream.

Types

type Document

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

Document The properties document in memory.

func New

func New() *Document

New is used to create a new and empty properties document.

It's used to generate a new document.

func (*Document) Accept

func (p *Document) Accept(f func(typo byte, value string, key string) bool)

Accept Traverse every element of the document, include comment.

The typo parameter special the element type. If typo is '#' or '!' means current element is a comment. If typo is ' ' means current element is a empty or a space line. If typo is '=' or ':' means current element is a key-value pair. The traverse will be terminated if f return false.

func (*Document) Get

func (p *Document) Get(key string) (value string, exist bool)

Get Retrieve the value from Document.

If the item is not exist, the exist is false.

func (*Document) Set

func (p *Document) Set(key string, value string)

Set Update the value of the item of the key.

Create a new item if the item of the key is not exist.

Jump to

Keyboard shortcuts

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