Skip to content

Commit 07f7852

Browse files
authored
Add CI Workflow (#6)
1 parent 82b408a commit 07f7852

File tree

5 files changed

+58
-8
lines changed

5 files changed

+58
-8
lines changed

.github/workflows/ci.yml

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
jobs:
8+
test:
9+
strategy:
10+
matrix:
11+
go-version: [1.18.x]
12+
os: [ubuntu-latest]
13+
runs-on: ${{ matrix.os }}
14+
steps:
15+
- name: Install Go
16+
uses: actions/setup-go@v2
17+
with:
18+
go-version: ${{ matrix.go-version }}
19+
- name: Checkout code
20+
uses: actions/checkout@v3
21+
- name: Linting
22+
uses: golangci/golangci-lint-action@v3
23+
with:
24+
version: latest
25+
- name: test
26+
run: go test -race ./...

.golangci.yml

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
run:
2+
tests: true
3+
4+
linters:
5+
enable:
6+
- govet
7+
- revive
8+
- gofumpt
9+
- gosec
10+
- unparam
11+
- goconst
12+
- prealloc
13+
- stylecheck
14+
- unconvert
15+
- errcheck
16+
- deadcode
17+
- ineffassign
18+
- structcheck
19+
- tparallel
20+
- whitespace
21+
- staticcheck
22+
- gosimple
23+
- gocritic

README.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# JoeJSON
22

3+
[![CI](https://github.com/sgarcez/joejson/actions/workflows/ci.yml/badge.svg)](https://github.com/sgarcez/joejson/actions?query=workflow%3Aci)
4+
[![Go Report Card](https://goreportcard.com/badge/github.com/sgarcez/joejson)](https://goreportcard.com/report/github.com/sgarcez/joejson)
5+
[![Go Reference](https://pkg.go.dev/badge/github.com/sgarcez/joejson.svg)](https://pkg.go.dev/github.com/sgarcez/joejson)
6+
37
A GeoJSON (RFC 7946) Go implementation.
48

59
## Features
@@ -18,4 +22,4 @@ A GeoJSON (RFC 7946) Go implementation.
1822
- [x] Polygon
1923
- [x] MultiPolygon
2024
- [x] GeometryCollection
21-
- [ ] Validation (antimeridian crossing, right hand rule winding, etc)
25+
- [ ] Validation (antimeridian crossing, right hand rule winding, etc)

feature.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ func (f Feature) WithPolygon(g Polygon) Feature {
9898
}
9999

100100
// AsPolygon casts the Feature's Geometry to a Polygon.
101-
func (f *Feature) AsPolygon() (Polygon, bool) {
101+
func (f Feature) AsPolygon() (Polygon, bool) {
102102
p, ok := f.geometry.(Polygon)
103103
return p, ok
104104
}
@@ -110,7 +110,7 @@ func (f Feature) WithMultiPolygon(g MultiPolygon) Feature {
110110
}
111111

112112
// AsMultiPolygon casts the Feature's Geometry to a MultiPolygon.
113-
func (f *Feature) AsMultiPolygon() (MultiPolygon, bool) {
113+
func (f Feature) AsMultiPolygon() (MultiPolygon, bool) {
114114
p, ok := f.geometry.(MultiPolygon)
115115
return p, ok
116116
}
@@ -122,7 +122,7 @@ func (f Feature) WithGeometryCollection(g GeometryCollection) Feature {
122122
}
123123

124124
// AsGeometryCollection casts Feature's Geometry to a GeometryCollection.
125-
func (f *Feature) AsGeometryCollection() (GeometryCollection, bool) {
125+
func (f Feature) AsGeometryCollection() (GeometryCollection, bool) {
126126
p, ok := f.geometry.(GeometryCollection)
127127
return p, ok
128128
}

geometrycollection.go

+1-4
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,7 @@ func (g *GeometryCollectionMember) AsMultiPolygon() (MultiPolygon, bool) {
121121

122122
// MarshalJSON is a custom JSON marshaller.
123123
func (g GeometryCollectionMember) MarshalJSON() ([]byte, error) {
124-
switch v := g.geometry.(type) {
125-
default:
126-
return json.Marshal(v)
127-
}
124+
return json.Marshal(g.geometry)
128125
}
129126

130127
// Type is the type of the Geometry.

0 commit comments

Comments
 (0)