Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug]: miss makezero in slice init #1029

Closed
alingse opened this issue May 27, 2024 · 0 comments
Closed

[bug]: miss makezero in slice init #1029

alingse opened this issue May 27, 2024 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@alingse
Copy link

alingse commented May 27, 2024

Describe the bug

I was running github actions to run linter makezero for top github golang repos.

see issues alingse/go-linter-runner#1

and the github actions output https://github.com/alingse/go-linter-runner/actions/runs/9243005104/job/25426566107

====================================================================================================
append to slice `fields` with non-zero initialized length at https://github.com/lindb/lindb/blob/main/prometheus/engine.go#L50:12
====================================================================================================
func (l *Logger) Log(keyvals ...interface{}) error {
	fields := make([]zap.Field, len(keyvals)/2)
	for i := 1; i < len(keyvals); i++ {
		key := fmt.Sprintf("%v", keyvals[i-1])
		fields = append(fields, logger.Any(key, keyvals[i]))
	}
	l.logger.Debug("prometheus", fields...)
	return nil
}

the fields will be [empty, empty, Any(k,v), Any(k,v)]

To Reproduce (Required)
Steps to reproduce the behavior:

Expected behavior (Required)

change fields := make([]zap.Field, len(keyvals)/2) to fields := make([]zap.Field, 0, len(keyvals)/2)

What's your LinDB version? (Required)
Insert output of lind version here.

Screenshots
If applicable, add screenshots to help explain your problem.

Additional context
Add any other context about the problem here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants