Documentation
¶
Overview ¶
Package systemd is a systemd unit file parser.
Index ¶
- Constants
- func IsLetter(ch rune) bool
- func Marshal(v any) ([]byte, error)
- func Unmarshal(data []byte, v any) error
- func Utf16Len(s string) uint32
- type AssignNode
- type CommentNode
- type FileNode
- type FindTokenOutput
- type Lexer
- type Marshaler
- type Node
- type NodePosition
- type Parser
- type ParserError
- type SectionNode
- type Token
- type TokenPosition
- type TokenType
- type Unmarshaler
- type ValueNode
Constants ¶
View Source
const ( TokenTypeComment = "comment" // For example: '# This is a comment' TokenTypeSection = "section" // For example: '[Unit]' TokenTypeKeyword = "keyword" // Text before '=' TokenTypeValue = "value" // Text after '=' TokenTypeAssign = "assign" // The '=' character TokenTypeContSign = "cont_sign" // The '\' at the end of the line TokenTypeEOF = "eof" // End of file )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AssignNode ¶
type AssignNode struct {
StartPos NodePosition
EndPos NodePosition
Name *string
Value *ValueNode
Documents []*CommentNode
}
AssignNode represents a key-value pair like 'Image=foo.image', altogether with its document comment.
func (*AssignNode) String ¶
func (a *AssignNode) String() string
type CommentNode ¶
type CommentNode struct {
StartPos NodePosition
EndPos NodePosition
Text *string
}
CommentNode represent the comment nodes in the file.
func (*CommentNode) String ¶
func (d *CommentNode) String() string
type FileNode ¶
type FileNode struct {
Documents []*CommentNode
Sections []*SectionNode
}
FileNode represents the whole Quadlet file.
func (*FileNode) FindToken ¶
func (q *FileNode) FindToken(position NodePosition) FindTokenOutput
FindToken method receives two parameter a line and a position number, then searches in the Quadlet and return with the token where the position is.
type FindTokenOutput ¶
type Lexer ¶
type NodePosition ¶
type NodePosition = TokenPosition
type Parser ¶
type Parser struct {
File *FileNode // The parsed output
Errors []ParserError // If there is any error during reading record it
Path string // Location of the file
LexerTokens []Token // Result of the lexer
// contains filtered or unexported fields
}
func NewParserFromMemory ¶
type ParserError ¶
type SectionNode ¶
type SectionNode struct {
StartPos NodePosition
EndPos NodePosition
Text *string
Assignments []*AssignNode
Documents []*CommentNode
}
SectionNode represent the sections, like '[Unit]', in the file.
func (*SectionNode) String ¶
func (s *SectionNode) String() string
type Token ¶
type Token struct {
StartPos TokenPosition // Where the token start
EndPos TokenPosition // Where the token ends
Position uint32 // Start index of token in the input
Length uint32 // Length of the token
Type TokenType // What kind of token it is
Text string // Content of the token
}
type TokenPosition ¶
type Unmarshaler ¶
Unmarshaler allows custom types to control their own systemd value decoding.
type ValueNode ¶
type ValueNode struct {
StartPos NodePosition
EndPos NodePosition
Value *string
}
Click to show internal directories.
Click to hide internal directories.