steamutils

package module
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2026 License: Unlicense Imports: 8 Imported by: 0

README

steamutils

Go Reference

steamutils is a Go package for reading and parsing Steam application installation data. It provides cross-platform support for Windows, Linux, and macOS.

CAUTION: This code was generated by an LLM. It has not been thoroughly tested or verified for production use. Please use with caution and verify behavior in your specific use case before deployment.

Installation

go get github.com/bomkz/steamutils

Features

  • Detect Steam installation path on Windows, Linux, and macOS
  • Parse Steam library folders configuration
  • Read application manifest files
  • Extract installed app metadata including name, build ID, size, and depots
  • Support for custom Steam paths and library locations
  • Cross-platform path handling

Quick Start

package main

import (
	"log"
	"github.com/bomkz/steamutils"
)

func main() {
	reader, err := steamutils.NewSteamReader(steamutils.SteamReaderConfig{})
	if err != nil {
		log.Fatal(err)
	}

	// Get all installed applications
	apps, err := reader.GetAllInstalledApps()
	if err != nil {
		log.Fatal(err)
	}

	for _, app := range apps {
		log.Printf("App ID: %s, Name: %s, Size: %d bytes", 
			app.AppID, app.Name, app.SizeOnDisk)
	}
}

Usage

Creating a SteamReader

Create a SteamReader with default settings:

reader, err := steamutils.NewSteamReader(steamutils.SteamReaderConfig{})

With custom Steam path:

config := steamutils.SteamReaderConfig{
	CustomSteamPath: "/path/to/steam",
}
reader, err := steamutils.NewSteamReader(config)
Retrieving Applications

Get all installed applications:

apps, err := reader.GetAllInstalledApps()

Get a specific application by app ID:

app, err := reader.GetInstalledAppByID("667970")
if err != nil {
	log.Fatal(err)
}
log.Printf("%s: %s", app.AppID, app.Name)
Querying Paths

Find the library path containing an app:

path, err := reader.FindAppIDPath("667970")

Get the build ID for an app:

buildID, err := reader.FindAppIDBuildID("667970")

Types

SteamReader

Provides methods to query Steam installation data.

SteamReaderConfig

Configuration for SteamReader:

  • LibraryVdfPathFinder: Custom function to find libraryfolders.vdf path
  • SteamPathFinder: Custom function to detect Steam installation path
  • CustomLibraryVdfPath: Override library VDF file location
  • CustomSteamPath: Override Steam installation path
  • FormatSteamPath: Normalize Steam path formatting (applies path normalization rules)
InstalledApp

Represents a Steam application:

  • AppID: Unique application identifier
  • Name: Display name
  • InstallDir: Installation directory name
  • FullPath: Full path to installation directory
  • BuildID: Build version identifier
  • SizeOnDisk: Size in bytes
  • LastUpdated: Last update timestamp
  • LastPlayed: Last play timestamp (0 if never played)
  • LibraryPath: Path to the library containing this app
  • InstalledDepots: List of content depots installed for this app
InstalledDepot

Represents a Steam depot (game content or DLC):

  • DepotID: Unique depot identifier
  • Manifest: Content manifest identifier
  • Size: Depot size in bytes
  • DLCAppID: Application ID if this is DLC content (empty for base game)

Platform Support

Windows: Detects Steam from Windows Registry

Linux: Checks standard Steam installation paths including:

  • ~/.steam/steam
  • ~/.local/share/Steam
  • Flatpak installation paths
  • Snap installation paths

macOS: Checks standard macOS Steam installation paths:

  • ~/Library/Application Support/Steam
  • Homebrew Cask installation paths

VDF File Format

The package includes a VDF (Valve Data Format) parser for reading Steam configuration files. The Unmarshal function parses VDF data into ordered maps.

data, _ := os.ReadFile("libraryfolders.vdf")
parsed, err := steamutils.Unmarshal(data)

Limitations and Warnings

IMPORTANT: This code was generated by an LLM and comes with the following caveats:

  1. Not thoroughly tested across all Steam configurations
  2. May not handle all VDF file variations
  3. Error handling may not cover all edge cases
  4. Performance not optimized for large Steam libraries
  5. Registry access on Windows may require appropriate permissions
  6. File I/O operations use standard Go libraries without retry logic
  7. Cross-platform testing is recommended before production use

Testing

Run the test suite:

go test ./...

Run tests with verbose output:

go test ./... -v

Run specific test:

go test -run TestGetSteamPath ./...

Error Handling

The package returns errors for common failure cases:

  • Steam installation not found
  • Library configuration file not accessible
  • Application manifest file missing or corrupted
  • VDF parsing errors

Check error values before using returned data:

app, err := reader.GetInstalledAppByID("999999")
if err != nil {
	log.Printf("Failed to get app: %v", err)
	return
}

Contributing

This is an LLM-generated project. If you discover issues or want to contribute improvements, please be aware that thorough testing and verification is essential.

License

This software is released into the public domain under the Unlicense. See LICENSE file for details.

Disclaimer

This package was generated by an LLM. It should be thoroughly tested and verified before use in any production environment. The authors are not responsible for any data loss, application crashes, or other issues that may arise from the use of this package.

Documentation

Overview

Package steamutils provides utilities for reading Steam application installation data.

CAUTION: This package was generated by an LLM. It has not been thoroughly tested or verified for production use. Use with caution and verify behavior before deploying to production.

The package supports Windows, Linux, and macOS platforms and can:

  • Detect Steam installation paths
  • Parse Steam library configuration files
  • Read application manifest files
  • Extract installed application metadata
  • Handle custom Steam paths and configurations

Basic usage:

reader, err := NewSteamReader(SteamReaderConfig{})
if err != nil {
	log.Fatal(err)
}
apps, err := reader.GetAllInstalledApps()

To specify a custom Steam path:

config := SteamReaderConfig{
	CustomSteamPath: "/custom/steam/path",
}
reader, err := NewSteamReader(config)

On Windows, Steam path is detected from the registry. On Linux and macOS, standard installation paths are checked. Custom paths can be provided via SteamReaderConfig.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetAutoLoggedInSteamUsername

func GetAutoLoggedInSteamUsername() (string, error)

GetAutoLoggedInSteamUsername returns Steam username on Linux This is less reliable than Windows but attempts to find it

func GetSteamPath

func GetSteamPath() (string, error)

GetSteamPath finds Steam's installation path on Linux Checks multiple common locations in order of likelihood

func Marshal

func Marshal(m *orderedmap.OrderedMap) ([]byte, error)

func Unmarshal

func Unmarshal(data []byte) (*orderedmap.OrderedMap, error)

Parses and unmarshals VDF file into map

Types

type InstalledApp

type InstalledApp struct {
	// AppID is the unique Steam application identifier.
	AppID string

	// Name is the display name of the application.
	Name string

	// InstallDir is the installation directory name (relative to steamapps/common).
	InstallDir string

	// FullPath is the complete filesystem path to the application directory.
	FullPath string

	// BuildID is the build version identifier.
	BuildID string

	// SizeOnDisk is the total installation size in bytes.
	SizeOnDisk int64

	// LastUpdated is the Unix timestamp of the last update.
	LastUpdated int64

	// LastPlayed is the Unix timestamp of the last play session.
	// Zero value indicates the application has never been played.
	LastPlayed int64

	// LibraryPath is the path to the Steam library containing this application.
	LibraryPath string

	// InstalledDepots is the list of content depots installed for this application.
	InstalledDepots []InstalledDepot
}

InstalledApp represents a Steam application with its installation details.

This type contains metadata about an installed game or application, including basic information, file locations, timestamps, and associated content depots.

WARNING: This type was generated by an LLM. Thoroughly test before production use.

type InstalledDepot

type InstalledDepot struct {
	// DepotID is the unique identifier for this depot.
	DepotID string

	// Manifest is the content manifest identifier for this depot version.
	Manifest string

	// Size is the total size of the depot in bytes.
	Size int64

	// DLCAppID contains the application ID if this depot is DLC content.
	// Empty string for base game depots.
	DLCAppID string
}

InstalledDepot represents a Steam depot (content package) installed for an application.

A depot is a container for game content. Most applications have one base game depot. DLC content is represented as separate depots with a DLCAppID value.

WARNING: This type was generated by an LLM. Thoroughly test before production use.

type SteamReader

type SteamReader struct {
	SteamReaderConfig SteamReaderConfig
	// contains filtered or unexported fields
}

SteamReader provides methods to query Steam installation and application data.

It reads and parses Steam's libraryfolders.vdf configuration file and application manifest files to extract metadata about installed applications and depots.

WARNING: This type was generated by an LLM. Thoroughly test before production use.

func NewSteamReader

func NewSteamReader(steamReaderConfig SteamReaderConfig) (steamreader SteamReader, err error)

NewSteamReader creates a new SteamReader with the provided configuration.

The function automatically detects the Steam installation path and library configuration unless custom paths are provided in SteamReaderConfig.

On Windows, the registry (HKEY_CURRENT_USER\Software\Valve\Steam) is checked. On Linux and macOS, standard installation paths are checked in order of likelihood.

Returns an error if Steam cannot be located or if libraryfolders.vdf cannot be read.

WARNING: This function was generated by an LLM. Thoroughly test before production use.

func (*SteamReader) FindAppIDBuildID

func (steamreader *SteamReader) FindAppIDBuildID(AppID string) (buildId string, err error)

FindAppIDBuildID returns the build ID for the specified application.

It locates the application in the library configuration and reads the appmanifest file to extract the build ID. Returns an error if the application is not found or the manifest file cannot be read.

func (*SteamReader) FindAppIDPath

func (steamreader *SteamReader) FindAppIDPath(targetAppID string) (string, error)

FindAppIDPath returns the Steam library path containing the specified application.

It searches through all configured library folders to find the application ID. Returns the library directory path where the application is installed. Returns an error if the application is not found in any library.

func (*SteamReader) GetAllInstalledApps

func (steamreader *SteamReader) GetAllInstalledApps() ([]InstalledApp, error)

GetAllInstalledApps returns a list of all installed Steam applications by reading appmanifest_<appid>.acf files from all Steam library folders.

It iterates through all configured library locations and scans for installed applications. Returns a slice of InstalledApp with full metadata including name, size, build ID, and installed content depots.

Returns an error if the library configuration cannot be parsed or if manifest files cannot be read. Applications with unreadable manifest files are skipped.

WARNING: This method was generated by an LLM. Thoroughly test before production use.

func (*SteamReader) GetInstalledAppByID

func (steamreader *SteamReader) GetInstalledAppByID(appID string) (*InstalledApp, error)

GetInstalledAppByID retrieves details for a specific installed app by its AppID.

It searches all configured library folders to locate the application and reads its manifest file to extract metadata. Returns a pointer to InstalledApp with all available information including name, size, build ID, and installed depots.

Returns an error if the application is not found in any library or if the manifest file cannot be read.

WARNING: This method was generated by an LLM. Thoroughly test before production use.

func (*SteamReader) GetLibraryVdfMap

func (steamreader *SteamReader) GetLibraryVdfMap() *orderedmap.OrderedMap

GetLibraryVdfMap returns the parsed library configuration data as an OrderedMap.

The returned map contains the structure of libraryfolders.vdf with library entries indexed by key (typically "0", "1", etc.).

func (*SteamReader) GetLibraryVdfPath

func (steamreader *SteamReader) GetLibraryVdfPath() string

GetLibraryVdfPath returns the path to the libraryfolders.vdf configuration file.

This file is typically located in Steam's config directory and contains the list of library folders and their installed applications.

func (*SteamReader) GetSteamPath

func (steamreader *SteamReader) GetSteamPath() string

GetSteamPath returns the Steam installation directory path.

If FormatSteamPath is enabled in SteamReaderConfig, the path is normalized with proper case handling and path separators. Returns the raw path otherwise.

type SteamReaderConfig

type SteamReaderConfig struct {
	// LibraryVdfPathFinder is a custom function to locate libraryfolders.vdf.
	// If nil, the default implementation checks the Steam directory.
	LibraryVdfPathFinder func(steamPath string) (string, error)

	// SteamPathFinder is a custom function to detect the Steam installation path.
	// If nil, platform-specific detection is used (registry on Windows, paths on Linux/macOS).
	SteamPathFinder func() (string, error)

	// CustomLibraryVdfPath overrides the detected libraryfolders.vdf path.
	// If set, LibraryVdfPathFinder is not called.
	CustomLibraryVdfPath string

	// CustomSteamPath overrides the detected Steam installation path.
	// If set, SteamPathFinder is not called.
	CustomSteamPath string

	// FormatSteamPath normalizes the Steam path formatting.
	// Applies path separator normalization and case corrections.
	// Only affects paths from the default SteamPathFinder.
	FormatSteamPath bool

	// UserName is used for Linux installations only, used to find steamPath
	UserName string
	// contains filtered or unexported fields
}

SteamReaderConfig provides configuration options for creating a new SteamReader.

LibraryVdfPathFinder and SteamPathFinder allow custom path detection logic. CustomLibraryVdfPath and CustomSteamPath override automatic detection. FormatSteamPath determines whether to normalize path formatting.

WARNING: This type was generated by an LLM. Thoroughly test before production use.

Jump to

Keyboard shortcuts

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