mirror of
https://github.com/mainflux/mainflux.git
synced 2025-04-27 13:48:49 +08:00
Gofmt
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
This commit is contained in:
parent
c12a88d12f
commit
d38ea79dde
@ -1,21 +1,21 @@
|
|||||||
package clients
|
package clients
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"strings"
|
|
||||||
"time"
|
|
||||||
"log"
|
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/mainflux/mainflux/config"
|
||||||
"github.com/mainflux/mainflux/db"
|
"github.com/mainflux/mainflux/db"
|
||||||
"github.com/mainflux/mainflux/models"
|
"github.com/mainflux/mainflux/models"
|
||||||
"github.com/mainflux/mainflux/config"
|
|
||||||
|
|
||||||
|
mqtt "github.com/eclipse/paho.mqtt.golang"
|
||||||
"github.com/krylovsk/gosenml"
|
"github.com/krylovsk/gosenml"
|
||||||
"gopkg.in/mgo.v2/bson"
|
"gopkg.in/mgo.v2/bson"
|
||||||
mqtt "github.com/eclipse/paho.mqtt.golang"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type (
|
type (
|
||||||
@ -75,7 +75,6 @@ func (mqc *MqttConn) MqttSub(cfg config.Config) {
|
|||||||
WriteStatusChannel = make(chan ChannelWriteStatus)
|
WriteStatusChannel = make(chan ChannelWriteStatus)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* WriteChannel()
|
* WriteChannel()
|
||||||
* Generic function that updates the channel value.
|
* Generic function that updates the channel value.
|
||||||
|
@ -34,7 +34,6 @@ type Config struct {
|
|||||||
InfluxDatabase string
|
InfluxDatabase string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func (cfg *Config) Parse() {
|
func (cfg *Config) Parse() {
|
||||||
|
|
||||||
var confFile string
|
var confFile string
|
||||||
|
@ -12,19 +12,19 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"time"
|
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/mainflux/mainflux/clients"
|
||||||
"github.com/mainflux/mainflux/db"
|
"github.com/mainflux/mainflux/db"
|
||||||
"github.com/mainflux/mainflux/models"
|
"github.com/mainflux/mainflux/models"
|
||||||
"github.com/mainflux/mainflux/clients"
|
|
||||||
|
|
||||||
"github.com/satori/go.uuid"
|
"github.com/satori/go.uuid"
|
||||||
"gopkg.in/mgo.v2/bson"
|
"gopkg.in/mgo.v2/bson"
|
||||||
|
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
"github.com/go-zoo/bone"
|
"github.com/go-zoo/bone"
|
||||||
)
|
)
|
||||||
@ -127,7 +127,8 @@ func GetChannels(w http.ResponseWriter, r *http.Request) {
|
|||||||
// Set default limit to -5
|
// Set default limit to -5
|
||||||
climit = -100
|
climit = -100
|
||||||
} else {
|
} else {
|
||||||
climit, err = strconv.Atoi(s); if err != nil {
|
climit, err = strconv.Atoi(s)
|
||||||
|
if err != nil {
|
||||||
w.WriteHeader(http.StatusBadRequest)
|
w.WriteHeader(http.StatusBadRequest)
|
||||||
str := `{"response": "wrong count limit"}`
|
str := `{"response": "wrong count limit"}`
|
||||||
io.WriteString(w, str)
|
io.WriteString(w, str)
|
||||||
@ -140,7 +141,8 @@ func GetChannels(w http.ResponseWriter, r *http.Request) {
|
|||||||
// Set default limit to -5
|
// Set default limit to -5
|
||||||
vlimit = -100
|
vlimit = -100
|
||||||
} else {
|
} else {
|
||||||
vlimit, err = strconv.Atoi(s); if err != nil {
|
vlimit, err = strconv.Atoi(s)
|
||||||
|
if err != nil {
|
||||||
w.WriteHeader(http.StatusBadRequest)
|
w.WriteHeader(http.StatusBadRequest)
|
||||||
str := `{"response": "wrong value limit"}`
|
str := `{"response": "wrong value limit"}`
|
||||||
io.WriteString(w, str)
|
io.WriteString(w, str)
|
||||||
@ -177,7 +179,6 @@ func GetChannel(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
id := bone.GetValue(r, "channel_id")
|
id := bone.GetValue(r, "channel_id")
|
||||||
|
|
||||||
|
|
||||||
var vlimit int
|
var vlimit int
|
||||||
var err error
|
var err error
|
||||||
s := r.URL.Query().Get("vlimit")
|
s := r.URL.Query().Get("vlimit")
|
||||||
@ -185,7 +186,8 @@ func GetChannel(w http.ResponseWriter, r *http.Request) {
|
|||||||
// Set default limit to -5
|
// Set default limit to -5
|
||||||
vlimit = -5
|
vlimit = -5
|
||||||
} else {
|
} else {
|
||||||
vlimit, err = strconv.Atoi(s); if err != nil {
|
vlimit, err = strconv.Atoi(s)
|
||||||
|
if err != nil {
|
||||||
w.WriteHeader(http.StatusBadRequest)
|
w.WriteHeader(http.StatusBadRequest)
|
||||||
str := `{"response": "wrong limit"}`
|
str := `{"response": "wrong limit"}`
|
||||||
io.WriteString(w, str)
|
io.WriteString(w, str)
|
||||||
@ -204,7 +206,6 @@ func GetChannel(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
w.WriteHeader(http.StatusOK)
|
w.WriteHeader(http.StatusOK)
|
||||||
res, err := json.Marshal(result)
|
res, err := json.Marshal(result)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -290,5 +291,3 @@ func DeleteChannel(w http.ResponseWriter, r *http.Request) {
|
|||||||
str := `{"response": "deleted", "id": "` + id + `"}`
|
str := `{"response": "deleted", "id": "` + id + `"}`
|
||||||
io.WriteString(w, str)
|
io.WriteString(w, str)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -21,8 +21,8 @@ import (
|
|||||||
"gopkg.in/mgo.v2/bson"
|
"gopkg.in/mgo.v2/bson"
|
||||||
|
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
"github.com/go-zoo/bone"
|
"github.com/go-zoo/bone"
|
||||||
)
|
)
|
||||||
@ -189,7 +189,6 @@ func UpdateDevice(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
Db := db.MgoDb{}
|
Db := db.MgoDb{}
|
||||||
Db.Init()
|
Db.Init()
|
||||||
defer Db.Close()
|
defer Db.Close()
|
||||||
|
12
main.go
12
main.go
@ -9,17 +9,17 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"github.com/fatih/color"
|
||||||
"strings"
|
"github.com/mainflux/mainflux/clients"
|
||||||
"strconv"
|
|
||||||
"github.com/mainflux/mainflux/config"
|
"github.com/mainflux/mainflux/config"
|
||||||
"github.com/mainflux/mainflux/db"
|
"github.com/mainflux/mainflux/db"
|
||||||
"github.com/mainflux/mainflux/servers"
|
"github.com/mainflux/mainflux/servers"
|
||||||
"github.com/mainflux/mainflux/clients"
|
"os"
|
||||||
"github.com/fatih/color"
|
|
||||||
"runtime"
|
"runtime"
|
||||||
"flag"
|
"strconv"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
type MainfluxLite struct {
|
type MainfluxLite struct {
|
||||||
|
@ -9,17 +9,15 @@
|
|||||||
package servers
|
package servers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"strconv"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
"github.com/mainflux/mainflux/controllers"
|
|
||||||
"github.com/mainflux/mainflux/config"
|
"github.com/mainflux/mainflux/config"
|
||||||
|
"github.com/mainflux/mainflux/controllers"
|
||||||
|
|
||||||
"github.com/go-zoo/bone"
|
"github.com/go-zoo/bone"
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
func HttpServer(cfg config.Config) {
|
func HttpServer(cfg config.Config) {
|
||||||
|
|
||||||
mux := bone.New()
|
mux := bone.New()
|
||||||
|
@ -9,12 +9,12 @@
|
|||||||
package servers
|
package servers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
|
||||||
"time"
|
|
||||||
"log"
|
"log"
|
||||||
"os"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
|
"os"
|
||||||
|
"testing"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/mainflux/mainflux/config"
|
"github.com/mainflux/mainflux/config"
|
||||||
"github.com/mainflux/mainflux/controllers"
|
"github.com/mainflux/mainflux/controllers"
|
||||||
@ -24,7 +24,6 @@ import (
|
|||||||
"gopkg.in/mgo.v2"
|
"gopkg.in/mgo.v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
func TestMain(m *testing.M) {
|
func TestMain(m *testing.M) {
|
||||||
// We are in testing - notify the program
|
// We are in testing - notify the program
|
||||||
// so that it is not confused if some other commad line
|
// so that it is not confused if some other commad line
|
||||||
@ -75,7 +74,6 @@ func TestServer(t *testing.T) {
|
|||||||
var cfg config.Config
|
var cfg config.Config
|
||||||
cfg.Parse()
|
cfg.Parse()
|
||||||
|
|
||||||
|
|
||||||
// Create a request to pass to our handler. We don't have any query parameters for now, so we'll
|
// Create a request to pass to our handler. We don't have any query parameters for now, so we'll
|
||||||
// pass 'nil' as the third parameter.
|
// pass 'nil' as the third parameter.
|
||||||
req, err := http.NewRequest("GET", "/status", nil)
|
req, err := http.NewRequest("GET", "/status", nil)
|
||||||
@ -102,4 +100,3 @@ func TestServer(t *testing.T) {
|
|||||||
t.Errorf("handler returned unexpected body: got %v want %v", rr.Body.String(), expected)
|
t.Errorf("handler returned unexpected body: got %v want %v", rr.Body.String(), expected)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user