utils

package
v0.0.0-...-5331e25 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2019 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Copyright 2017 Northern.tech AS

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Copyright 2017 Northern.tech AS

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type KeyValParser

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

KeyValParser is a parser that reading lines in format 'key=value\n'. Entries collected during parsing and can be retrieved by calling KeyValParser.Collect(). Keys appearing multiple times will have their values merged into a single list.

func (*KeyValParser) Collect

func (k *KeyValParser) Collect() map[string][]string

Collect() data read during Parse(). Map keys correspond to entry names, while map values is a list of entry values collected for particular key.

For instance, input:

foo=bar
baz=1
baz=zen

will be converted to:

map[string][]string{
    "foo": []string{"bar"},
    "baz": []string{"1", "zen"}
}

If no data was collected during Parse(), returns nil. A non-nil may be returned regardless of errors reported byParse(), in such case, the data will contain entries collected up to a point when error was detected.

func (*KeyValParser) Parse

func (k *KeyValParser) Parse(raw io.Reader) error

type LimitedWriter

type LimitedWriter struct {
	W io.Writer // underlying writer
	N uint64    // number of bytes remaining
}

func (*LimitedWriter) Write

func (lw *LimitedWriter) Write(p []byte) (int, error)

type ProgressWriter

type ProgressWriter struct {
	Out io.Writer // progress output
	N   int64     // size of the input
	// contains filtered or unexported fields
}

func (*ProgressWriter) Write

func (p *ProgressWriter) Write(data []byte) (int, error)

Jump to

Keyboard shortcuts

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