• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

hamba / avro / 20232551930

15 Dec 2025 12:41PM UTC coverage: 94.648% (-0.09%) from 94.736%
20232551930

Pull #587

github

web-flow
Merge b834011f5 into 9af4aa479
Pull Request #587: support reseting encoder to reduce load on GC.

15 of 22 new or added lines in 2 files covered. (68.18%)

10 existing lines in 1 file now uncovered.

6278 of 6633 relevant lines covered (94.65%)

31053.99 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

85.0
/encoder.go
1
package avro
2

3
import (
4
        "io"
5
)
6

7
// Encoder writes Avro values to an output stream.
8
type Encoder struct {
9
        s Schema
10
        w *Writer
11
}
12

13
// NewEncoder returns a new encoder that writes to w using schema s.
14
func NewEncoder(s string, w io.Writer) (*Encoder, error) {
410✔
15
        sch, err := Parse(s)
410✔
16
        if err != nil {
412✔
17
                return nil, err
2✔
18
        }
2✔
19
        return NewEncoderForSchema(sch, w), nil
408✔
20
}
21

22
// NewEncoderForSchema returns a new encoder that writes to w using schema.
23
func NewEncoderForSchema(schema Schema, w io.Writer) *Encoder {
412✔
24
        return DefaultConfig.NewEncoder(schema, w)
412✔
25
}
412✔
26

27
// Encode writes the Avro encoding of v to the stream.
28
func (e *Encoder) Encode(v any) error {
412✔
29
        e.w.WriteVal(e.s, v)
412✔
30
        _ = e.w.Flush()
412✔
31
        return e.w.Error
412✔
32
}
412✔
33

34
// Reset resets the encoder to write to a new io.Writer.
NEW
35
func (e *Encoder) Reset(w io.Writer) {
×
NEW
36
        e.w.Reset(w)
×
NEW
37
}
×
38

39
// Marshal returns the Avro encoding of v.
40
func Marshal(schema Schema, v any) ([]byte, error) {
2,104✔
41
        return DefaultConfig.Marshal(schema, v)
2,104✔
42
}
2,104✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc