This directory contains standalone examples demonstrating the HDF5 Go library features.
Each example is in its own directory with a main.go file. Run them using go run:
# Basic usage example
go run examples/01-basic/main.go
# List objects in HDF5 file
go run examples/02-list-objects/main.go
# Read dataset values
go run examples/03-read-dataset/main.go
# Read variable-length strings
go run examples/04-vlen-strings/main.go
# Comprehensive feature demonstration
go run examples/05-comprehensive/main.goOr build and run:
cd examples/01-basic
go build
./01-basic # or 01-basic.exe on WindowsEach example has its own README.md with detailed explanations, code walkthroughs, and use cases.
01-basic - Basic Usage
Best starting point for new users!
Demonstrates:
- Opening HDF5 files
- Reading superblock information
- Walking file structure
- Automatic test file generation with Python
02-list-objects - File Navigation
Demonstrates:
- Traversing groups and datasets
- Reading object hierarchy
- Walking nested structures
- Building object indexes
03-read-dataset - Dataset Reading
Demonstrates:
- Reading numeric datasets (floats, integers)
- Reading matrices (2D data)
- Reading multiple datasets
- Getting dataset metadata
- Data verification
04-vlen-strings - Variable-Length Strings
Demonstrates:
- Reading variable-length strings via Global Heap
- Global Heap architecture
- String storage mechanisms
- Compound types with vlen string members
05-comprehensive - Full Feature Demo
Complete demonstration of all library features!
Demonstrates:
- All superblock versions (0, 2, 3)
- Object headers (v1 + v2)
- All group formats
- All dataset layouts
- GZIP compression
- All datatypes
- Production readiness showcase (~98%)
Examples expect test HDF5 files in ../../testdata/:
v0.h5- HDF5 version 0 (earliest format)v2.h5- HDF5 version 2 (1.8.x format)v3.h5- HDF5 version 3 (latest format)with_groups.h5- File with nested groupsvlen_strings.h5- File with variable-length strings
Most examples auto-generate test files if Python with h5py is available.
- Go 1.25 or later
- For test file generation (optional): Python 3 with
h5pyandnumpy
Install Python dependencies:
pip install h5py numpyNote: Python is optional. You can use your own HDF5 files or download test files.
file, err := hdf5.Open("data.h5")
if err != nil {
log.Fatal(err)
}
defer file.Close()file.Walk(func(path string, obj hdf5.Object) {
switch v := obj.(type) {
case *hdf5.Group:
fmt.Printf("Group: %s\n", path)
case *hdf5.Dataset:
fmt.Printf("Dataset: %s\n", path)
}
})// Numeric data
values, err := dataset.Read()
// String data
strings, err := dataset.ReadStrings()
// Compound data (structs)
records, err := dataset.ReadCompound()From repository root:
make examplesThis builds all examples to verify they compile correctly.
- Installation Guide - Setup and verification
- Quick Start Guide - Get started in 5 minutes
- Reading Data Guide - Comprehensive reading guide
- Datatypes Guide - Type mapping and conversion
- Troubleshooting - Common issues and solutions
- FAQ - Frequently asked questions
- Main README - Library overview
- ROADMAP - Future plans
- API Documentation - GoDoc
- Architecture Overview - How it works
Last Updated: 2025-10-29 Version: 0.10.0-beta