Skip to content

Commit 48df043

Browse files
committed
minor rework (lint,..)
add license & go report badge
1 parent f79be42 commit 48df043

File tree

6 files changed

+24
-11
lines changed

6 files changed

+24
-11
lines changed

Diff for: LICENSE.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
The MIT License (MIT)
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4+
5+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6+
7+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Diff for: README.md

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
[![Travis branch](https://img.shields.io/travis/mch1307/gomotics/master.svg)](https://travis-ci.org/mch1307/gomotics)
44
[![Coverage Status](https://coveralls.io/repos/github/mch1307/gomotics/badge.svg?branch=master)](https://coveralls.io/github/mch1307/gomotics?branch=master)
5+
[![Go Report Card](https://goreportcard.com/badge/mch1307/gomotics)](http://goreportcard.com/report/mch1307/gomotics)
6+
[![license](https://img.shields.io/github/license/mch1307/gomotics.svg)](https://github.com/mch1307/gomotics/blob/master/LICENSE.md)
57

68
Work In Progress
79

Diff for: nhc/nhc_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ var (
2828
`
2929
testConf = config.NhcConf{Host: "localhost", Port: 8000}
3030
command = Event{ID: 1, Value: 100}
31-
myCmd NhcSimpleCmd
31+
myCmd SimpleCmd
3232
)
3333

3434
type Sessions []*Session

Diff for: nhc/router.go

-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ func SaveItem(item MessageIntf) {
1818
}
1919

2020
// Route parse and route incoming message the right handler
21-
// ugly, code repetition with json parsing?
2221
func Route(msg Message) {
2322
if msg.Cmd == "listlocations" {
2423
if err := json.Unmarshal(msg.Data, &nhcLocations); err != nil {

Diff for: nhc/types.go

+13-8
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,15 @@ package nhc
33
import "encoding/json"
44

55
const (
6-
RegisterCMD = "{\"cmd\":\"startevents\"}"
7-
ListActions = "{\"cmd\":\"listactions\"}"
8-
ListLocations = "{\"cmd\":\"listlocations\"}"
9-
ListEnergies = "{\"cmd\":\"listenergy\"}"
6+
// RegisterCMD holds NHC startevents
7+
RegisterCMD = "{\"cmd\":\"startevents\"}"
8+
// ListActions holds NHC listactions
9+
ListActions = "{\"cmd\":\"listactions\"}"
10+
// ListLocations holds NHC listlocations
11+
ListLocations = "{\"cmd\":\"listlocations\"}"
12+
// ListEnergies holds NHC listenergy
13+
ListEnergies = "{\"cmd\":\"listenergy\"}"
14+
// ListThermostats holds NHC listthermostat
1015
ListThermostats = "{\"cmd\":\"listthermostat\"}"
1116
)
1217

@@ -22,22 +27,22 @@ type GenericItem struct {
2227
}
2328

2429
// Message generic struct to hold nhc messages
25-
// used to identify the message type before futher parsing
30+
// used to identify the message type before further parsing
2631
type Message struct {
2732
Cmd string `json:"cmd"`
2833
Event string `json:"event"`
2934
Data json.RawMessage
3035
}
3136

32-
// NhcSimpleCmd type holding a nhc command
33-
type NhcSimpleCmd struct {
37+
// SimpleCmd type holding a nhc command
38+
type SimpleCmd struct {
3439
Cmd string `json:"cmd"`
3540
ID int `json:"id"`
3641
Value int `json:"value1"`
3742
}
3843

3944
// Stringify return the string version of SimpleCmd
40-
func (sc NhcSimpleCmd) Stringify() string {
45+
func (sc SimpleCmd) Stringify() string {
4146
tmp, _ := json.Marshal(sc)
4247
return string(tmp)
4348
}

Diff for: server/server.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ func nhcCmd(w http.ResponseWriter, r *http.Request) {
8282
if err != nil {
8383
fmt.Println("invalid request: value should be numeric")
8484
}
85-
var myCmd nhc.NhcSimpleCmd
85+
var myCmd nhc.SimpleCmd
8686
myCmd.Cmd = "executeactions"
8787
myCmd.ID = id
8888
myCmd.Value = val

0 commit comments

Comments
 (0)