A cross-platform Go library providing normalized battery information with consistent units across operating systems.
Battery is a cross-platform Go library that provides normalized battery information from various operating systems. It gives developers access to battery state, capacity, charge rate, and voltage values in consistent units like mW, mWh, and V. The library abstracts system-specific implementations to deliver a unified interface for battery monitoring across different platforms.
Go developers who need to programmatically access battery information in their applications, particularly those building system monitoring tools, power management utilities, or cross-platform desktop applications.
Developers choose Battery because it provides a clean, typed API that works consistently across multiple operating systems without requiring platform-specific code. It normalizes battery data into standard units and handles the complexities of different system implementations transparently.
cross-platform, normalized battery information library
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Supports Linux, macOS, Windows, and multiple BSD variants, abstracting system-specific details to provide a unified interface, as highlighted in the README's list of supported systems.
Returns battery metrics like capacity and charge in consistent units such as mWh and V, recalculated as necessary, as shown in the code example with fields like Current and Full in mWh.
Provides strongly-typed battery information through a clean Go API, making it easy to integrate into Go applications without manual type conversions.
Can retrieve information from all batteries present in a system using the GetAll() function, demonstrated in the README's code example with iteration over batteries.
Comes with a command-line utility that mimics acpi -b, useful for quick testing or scripting, with installation instructions provided in the README.
Relies on underlying operating system APIs, which can lead to inconsistencies or failures on unsupported or poorly documented systems, potentially requiring platform-specific troubleshooting.
Only provides battery information; developers needing other system metrics (e.g., CPU, memory) must use additional libraries, as it's focused solely on battery monitoring.
The library does not offer event-driven updates for battery changes, requiring manual polling which might be inefficient for real-time applications, as evident from the polling-based GetAll() approach.
As a cross-platform library, there may be bugs or inaccuracies on certain operating systems, especially older or less common ones, despite the normalization efforts.