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

vinyl-linux / mint / 5276909268
94%

Build:
DEFAULT BRANCH: main
Ran 15 Jun 2023 09:07AM UTC
Jobs 1
Files 16
Run time 1s
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

pending completion
5276909268

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

Jobs
ID Job ID Ran Files Coverage
1 5276909268.1 15 Jun 2023 09:07AM UTC 16
93.71
GitHub Action Run
Source Files on build 5276909268
  • Tree
  • List 16
  • Changed 5
  • Source Changed 0
  • Coverage Changed 5
Coverage ∆ File Lines Relevant Covered Missed Hits/Line
  • Back to Repo
  • 9f0a3e2c on github
  • Prev Build on main (#5266931200)
  • Next Build on main (#6677539384)
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

© 2025 Coveralls, Inc