Skip to content

Commit

Permalink
Merge branch 'release/v0.5.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisHines committed Jan 4, 2020
2 parents 07c9b44 + e81e8f5 commit 3be5f6a
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 177 deletions.
5 changes: 1 addition & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
_testdata/
_testdata2/
logfmt-fuzz.zip
logfmt.test.exe
.vscode/
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ go:
- "1.9.x"
- "1.10.x"
- "1.11.x"
- "1.12.x"
- "1.13.x"
- "tip"

before_install:
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.5.0] - 2020-01-03

### Changed
- Remove the dependency on github.com/kr/logfmt by [@ChrisHines]
- Move fuzz code to github.com/go-logfmt/fuzzlogfmt by [@ChrisHines]

## [0.4.0] - 2018-11-21

### Added
Expand All @@ -30,6 +36,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Decoder by [@ChrisHines]
- MarshalKeyvals by [@ChrisHines]

[0.5.0]: https://github.com/go-logfmt/logfmt/compare/v0.4.0...v0.5.0
[0.4.0]: https://github.com/go-logfmt/logfmt/compare/v0.3.0...v0.4.0
[0.3.0]: https://github.com/go-logfmt/logfmt/compare/v0.2.0...v0.3.0
[0.2.0]: https://github.com/go-logfmt/logfmt/compare/v0.1.0...v0.2.0
Expand Down
41 changes: 0 additions & 41 deletions decode-bench_test.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
package logfmt

import (
"bufio"
"bytes"
"testing"

kr "github.com/kr/logfmt"
)

func BenchmarkDecodeKeyval(b *testing.B) {
Expand Down Expand Up @@ -35,41 +32,3 @@ func BenchmarkDecodeKeyval(b *testing.B) {
}
}
}

func BenchmarkKRDecode(b *testing.B) {
const rows = 10000
data := []byte{}
for i := 0; i < rows; i++ {
data = append(data, "a=1 b=\"bar\" ƒ=2h3s r=\"esc\\tmore stuff\" d x=sf \n"...)
}

b.SetBytes(int64(len(data)))
b.ResetTimer()
for i := 0; i < b.N; i++ {
var (
s = bufio.NewScanner(bytes.NewReader(data))
err error
j = 0
dh discardHandler
)
for err == nil && s.Scan() {
err = kr.Unmarshal(s.Bytes(), &dh)
j++
}
if err == nil {
err = s.Err()
}
if err != nil {
b.Errorf("got %v, want %v", err, nil)
}
if j != rows {
b.Errorf("got %v, want %v", j, rows)
}
}
}

type discardHandler struct{}

func (discardHandler) HandleLogfmt(key, val []byte) error {
return nil
}
6 changes: 3 additions & 3 deletions decode.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ key:
dec.pos += p
if dec.pos > start {
dec.key = line[start:dec.pos]
if multibyte && bytes.IndexRune(dec.key, utf8.RuneError) != -1 {
if multibyte && bytes.ContainsRune(dec.key, utf8.RuneError) {
dec.syntaxError(invalidKeyError)
return false
}
Expand All @@ -97,7 +97,7 @@ key:
dec.pos += p
if dec.pos > start {
dec.key = line[start:dec.pos]
if multibyte && bytes.IndexRune(dec.key, utf8.RuneError) != -1 {
if multibyte && bytes.ContainsRune(dec.key, utf8.RuneError) {
dec.syntaxError(invalidKeyError)
return false
}
Expand All @@ -110,7 +110,7 @@ key:
dec.pos = len(line)
if dec.pos > start {
dec.key = line[start:dec.pos]
if multibyte && bytes.IndexRune(dec.key, utf8.RuneError) != -1 {
if multibyte && bytes.ContainsRune(dec.key, utf8.RuneError) {
dec.syntaxError(invalidKeyError)
return false
}
Expand Down
126 changes: 0 additions & 126 deletions fuzz.go

This file was deleted.

2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module github.com/go-logfmt/logfmt

require github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515
go 1.13
2 changes: 0 additions & 2 deletions go.sum

This file was deleted.

0 comments on commit 3be5f6a

Please sign in to comment.