Skip to content

Comments

fix: align Docker Go version with go.mod and optimize logger#596

Open
hobostay wants to merge 1 commit intosipeed:mainfrom
hobostay:fix/build-version-and-logger-optimization
Open

fix: align Docker Go version with go.mod and optimize logger#596
hobostay wants to merge 1 commit intosipeed:mainfrom
hobostay:fix/build-version-and-logger-optimization

Conversation

@hobostay
Copy link

This PR fixes build consistency issues and optimizes the logger for better memory efficiency.

Changes

Dockerfile

  • Updated base image from golang:1.26.0-alpine to golang:1.25-alpine
  • Aligns with go.mod which specifies go 1.25.7
  • Prevents potential build failures due to version mismatch

pkg/logger/logger.go

  • Optimized file write operation by using append(jsonData, '\n') instead of string(jsonData) + "\n"
  • This avoids an unnecessary string allocation and conversion
  • Added explicit empty string assignment for fieldStr when no fields are present
  • Important for the project's goal of running on devices with <10MB RAM

Benefits

  1. Build consistency: Docker build now uses the same Go version as go.mod
  2. Memory efficiency: Reduced allocations in the hot logging path
  3. Performance: Single Write call instead of WriteString with string concatenation

Testing

  • No functional changes to logging behavior
  • All log output remains identical
  • Memory allocations reduced in log path

Co-Authored-By: Claude Sonnet 4.6 noreply@anthropic.com

- Update Dockerfile to use golang:1.25-alpine to match go.mod (go 1.25.7)
- Optimize logger by avoiding string concatenation in file writes
- Add explicit empty string assignment for fieldStr when no fields

These changes improve build consistency and reduce memory allocations
in the hot logging path, which is important for the project's goal
of running on resource-constrained devices (<10MB RAM).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@xiaket
Copy link
Collaborator

xiaket commented Feb 21, 2026

Can you please update this PR to use the default PR template?

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.

2 participants