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

vinyl-linux / mint / 5276854462 / 1
94%
main: 94%

Build:
Build:
LAST BUILD BRANCH: refs/tags/v0.4.3
DEFAULT BRANCH: main
Ran 15 Jun 2023 09:03AM UTC
Files 16
Run time 0s
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

15 Jun 2023 09:01AM UTC coverage: 93.712%. First build
5276854462.1

push

github

jspc
Set empty collections to nil value

Given a type:

```golang
type Foo struct {
     Bar []string
}
```

When `Foo.Bar` is uninitialised/ `nil`, we Marshall with a Len of
0. When we then Unmarshall we initialise a `[]string` of length 0.

The problem here is that a `nil` slice and a slice of `len()` 0 are two
different things. Thus, when we try:

```golang
in := new(Foo)
in.Marshall(buf)

out := new(Foo)
out.Unmarshall(buf)
``

our types don't match up.

By testing whether `f.Len() == 0` and setting `Foo.Bar` as the nil
value, rather than anything else, we know our collection should be nil.

Of course, this wont work if the collection _should_ be of length 0.

1073 of 1145 relevant lines covered (93.71%)

3138.07 hits per line

Source Files on job 5276854462.1
  • Tree
  • List 0
  • Changed 0
  • Source Changed 0
  • Coverage Changed 0
Coverage ∆ File Lines Relevant Covered Missed Hits/Line
  • Back to Build 5276854462
  • 22e0d2c3 on github
  • Next Job for on nil_empty_collections (#5276861276.1)
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