file

package
v1.2.23 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Copyright Consensys Software Inc.

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.

SPDX-License-Identifier: Apache-2.0

Copyright Consensys Software Inc.

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.

SPDX-License-Identifier: Apache-2.0

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReadAndUncompress

func ReadAndUncompress(filename string) (string, []byte, error)

ReadAndUncompress reads a given file and, if its extension indicates it is compressed, then it decompresses it before returning the decompressed byte and the underlying filename (e.g. if original filename was "file.lt.gz" then it returns "file.lt"). Supported compression formats are "bz2" and "gz".

func ReadInputFileAsLines

func ReadInputFileAsLines(filename string) []string

ReadInputFileAsLines reads an input file as a sequence of lines.

Types

type Path

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

Path is a construct for describing paths through trees. A path can be either *absolute* or *relative*. An absolute path always starts from the root of the tree, whilst a relative path can begin from any point within the tree.

func NewAbsolutePath

func NewAbsolutePath(segments ...string) Path

NewAbsolutePath constructs a new absolute path from the given segments.

func NewRelativePath

func NewRelativePath(segments ...string) Path

NewRelativePath constructs a new absolute path from the given segments.

func (*Path) Compare

func (p *Path) Compare(other Path) int

Compare two paths lexicographically.

func (*Path) Dehead

func (p *Path) Dehead() *Path

Dehead removes the head from this path, returning an otherwise identical path. Observe that, if this were absolute, it is no longer!

func (*Path) Depth

func (p *Path) Depth() uint

Depth returns the number of segments in this path (a.k.a its depth).

func (*Path) Equals

func (p *Path) Equals(other Path) bool

Equals determines whether two paths are the same.

func (*Path) Extend

func (p *Path) Extend(tail string) *Path

Extend returns this path extended with a new innermost segment.

func (*Path) Get

func (p *Path) Get(nth uint) string

Get returns the nth segment of this path.

func (*Path) GobDecode

func (p *Path) GobDecode(data []byte) error

GobDecode a previously encoded option

func (*Path) GobEncode

func (p *Path) GobEncode() (data []byte, err error)

GobEncode an option. This allows it to be marshalled into a binary form.

func (*Path) Head

func (p *Path) Head() string

Head returns the first (i.e. outermost) segment in this path.

func (*Path) IsAbsolute

func (p *Path) IsAbsolute() bool

IsAbsolute determines whether or not this is an absolute path.

func (*Path) Parent

func (p *Path) Parent() *Path

Parent returns the parent of this path.

func (*Path) PrefixOf

func (p *Path) PrefixOf(other Path) bool

PrefixOf checks whether this path is a prefix of the other.

func (*Path) PushRoot

func (p *Path) PushRoot(tail string) *Path

PushRoot converts a relative path into an absolute path by pushing the "root" of the tree onto the head (i.e. outermost) position.

func (*Path) Slice

func (p *Path) Slice(start uint) *Path

Slice returns the subpath starting from the given segment.

func (*Path) String

func (p *Path) String() string

String returns a string representation of this path.

func (*Path) Tail

func (p *Path) Tail() string

Tail returns the last (i.e. innermost) segment in this path.

Jump to

Keyboard shortcuts

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