Skip to content

Conversation

abice
Copy link
Owner

@abice abice commented Aug 2, 2025

Fixes #279

Didn't realize go has a way to grab build info from the runtime, pretty neat!

This pull request introduces functionality to initialize and manage versioning metadata for the application. The most important changes include adding a new initializeVersion function to extract build information and modifying the main function to invoke this new functionality.

Versioning functionality:

  • Added initializeVersion function: This function uses the debug.ReadBuildInfo method to retrieve build metadata, including version, commit hash, build date, and whether the source was modified. The metadata is stored in global variables for use across the application. (main.go, main.goR51-R81)
  • Imported runtime/debug package: This import enables the use of debug.ReadBuildInfo for accessing build metadata. (main.go, main.goR8)

Code refinement:

  • Updated out function signature: Changed the variadic parameter type from interface{} to any, aligning with Go's updated type alias for improved readability. (main.go, main.goR51-R81)

@abice abice force-pushed the abice/runtimeVersion branch from 7969a3b to 33f1225 Compare August 2, 2025 17:16
@abice abice requested a review from Copilot August 2, 2025 17:19
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements automatic version extraction from Go runtime build information, replacing reliance on build-time variable injection. The implementation uses Go's runtime/debug package to dynamically retrieve version, commit hash, build date, and modification status from the binary's embedded metadata.

  • Added initializeVersion() function that extracts build metadata from Go runtime
  • Modified test expectations to match the new dynamic version initialization behavior
  • Updated function signature to use any type alias instead of interface{}

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
main.go Implements version initialization using runtime/debug and calls it in main function
main_test.go Updates test to call initialization and adjusts expected values for runtime-extracted metadata

@coveralls
Copy link

coveralls commented Aug 2, 2025

Coverage Status

coverage: 92.633% (-1.1%) from 93.778%
when pulling ee44a6c on abice/runtimeVersion
into f44f518 on master.

@abice abice force-pushed the abice/runtimeVersion branch from 33f1225 to ee44a6c Compare August 2, 2025 17:22
@abice abice merged commit 42b1ed5 into master Aug 2, 2025
5 checks passed
@abice abice deleted the abice/runtimeVersion branch August 2, 2025 17:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Aadd version info output
2 participants