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

vinyl-linux / mint
94%
main: 94%

Build:
Build:
LAST BUILD BRANCH: refs/tags/v0.4.3
DEFAULT BRANCH: main
Repo Added 28 May 2023 01:47PM UTC
Files 19
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

LAST BUILD ON BRANCH nil_empty_collections
branch: nil_empty_collections
CHANGE BRANCH
x
Reset
  • nil_empty_collections
  • benchmarking
  • code_generation
  • complex_marshall_support
  • default-build-perms
  • documentation
  • enums
  • main
  • refs/heads/main
  • refs/heads/move_binary_out
  • refs/tags/0.1.0
  • refs/tags/v0.2.0
  • refs/tags/v0.3.0
  • refs/tags/v0.4.0
  • refs/tags/v0.4.1
  • refs/tags/v0.4.2
  • refs/tags/v0.4.3
  • run_ci_on_pr
  • to_from_binary
  • uint16_type
  • updateses
  • uuid_type

pending completion
5276861276

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

Relevant lines Covered
Build:
Build:
1145 RELEVANT LINES 1073 COVERED LINES
3138.07 HITS PER LINE
Source Files on nil_empty_collections
  • Tree
  • List 16
  • Changed 0
  • Source Changed 0
  • Coverage Changed 0
Coverage ∆ File Lines Relevant Covered Missed Hits/Line

Recent builds

Builds Branch Commit Type Ran Committer Via Coverage
5276861276 nil_empty_collections 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 probl... push 15 Jun 2023 09:03AM UTC jspc github pending completion  
5276854462 nil_empty_collections 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 probl... push 15 Jun 2023 09:03AM UTC jspc github pending completion  
See All Builds (78)
  • Repo on GitHub
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