package module
Version: v0.0.0-...-d9b9230 Latest Latest

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

Go to latest
Published: Oct 21, 2019 License: Apache-2.0 Imports: 16 Imported by: 0


go-asdf GoDoc Build Status codecov Go Report Card Apache 2.0 license

Advanced Scientific Data Format reader library in pure Go.

The blocks are eagerly read and uncompressed. The tree is mapped with gabs.

import ""

fmt.Println(asdf.OpenFile("path/to/file.asdf", nil).Tree)

...are welcome, see CONTRIBUTING and code of conduct.


Apache 2.0, see LICENSE.




View Source
const (
	// CompressionNone corresponds to no compression.
	CompressionNone CompressionKind = iota
	// CompressionZLIB corresponds to zlib compression: balanced compression/decompression performance, moderate compression ratio.
	CompressionZLIB CompressionKind = iota
	// CompressionBZIP2 corresponds to bzip2 compression: slow compression/decompression, good compression ratio.
	CompressionBZIP2 CompressionKind = iota
	// CompressionLZ4 corresponds to lz4 compression: very fast compression/decompression, poor compression ratio for complex data, moderate/good for ordered.
	CompressionLZ4 CompressionKind = iota

	// FlagStreamed denotes a streamed block. Not used anywhere yet.
	FlagStreamed uint32 = 1


This section is empty.


func Grep

func Grep(reader io.Reader, needle []byte) (int, error)

Grep does the same as the UNIX `grep -m1` command: search for the first occurrence of the specified byte sequence in a byte stream. -1 is returned if there is no match.


type Block

type Block struct {
	// Data is the block's payload.
	Data []byte
	// Flags is the block's flags. The 1.x standard does not define any flags except `FlagStreamed`.
	Flags uint32
	// Compression is the block's compression type: none, zlib, bzip2 or lz4.
	Compression CompressionKind
	// contains filtered or unexported fields

Block corresponds to an ASDF block.

func ReadBlock

func ReadBlock(reader io.Reader) (*Block, error)

ReadBlock loads another block from the specified reader. That block may be compressed, call `Uncompress()` to obtain the original Data.

func (*Block) Uncompress

func (block *Block) Uncompress() error

Uncompress switches the block's compression to "none", uncompressing `Data` in-place as needed and checking the checksum.

type CompressionKind

type CompressionKind int

CompressionKind indicates the block compression type: none, zlib, bzip2 or lz4.

type File

type File struct {
	// FormatVersion corresponds to the contents of #ASDF header comment.
	FormatVersion semver.Version
	// FormatVersion corresponds to the contents of #ASDF_STANDARD header comment.
	StandardVersion semver.Version

File is the top level, ASDF file type.

func Open

func Open(reader io.ReadSeeker, progress ProgressCallback) (*File, error)

Open reads ASDF from a seekable reader.

func OpenFile

func OpenFile(fileName string, progress ProgressCallback) (*File, error)

OpenFile reads ASDF from the file system.

type ProgressCallback

type ProgressCallback func(done, total int)

ProgressCallback allows tracking the file loading progress. Both done *and* total will grow dynamically.


Path Synopsis

Jump to

Keyboard shortcuts

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