Skip to content

Commit

Permalink
gateway: reformat with gofumports
Browse files Browse the repository at this point in the history
  • Loading branch information
hg committed May 27, 2021
1 parent 291b3ae commit 693b5e8
Show file tree
Hide file tree
Showing 13 changed files with 43 additions and 29 deletions.
5 changes: 3 additions & 2 deletions gateway/airkaz/airkaz.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ package airkaz

import (
"encoding/json"
"regexp"
"time"

"github.com/hg/airmon/influx"
"github.com/hg/airmon/logger"
"github.com/hg/airmon/net"
Expand All @@ -10,8 +13,6 @@ import (
influxdb2 "github.com/influxdata/influxdb-client-go/v2"
"github.com/pkg/errors"
"go.uber.org/zap"
"regexp"
"time"
)

var dataRe = regexp.MustCompile(`(?si)<script.*>.*sensors_data\s*=\s*(\[.+])</script`)
Expand Down
5 changes: 3 additions & 2 deletions gateway/ceb/ceb.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
package ceb

import (
"strings"
"time"

"github.com/hg/airmon/influx"
"github.com/hg/airmon/logger"
"github.com/hg/airmon/net"
"github.com/hg/airmon/storage"
"github.com/hg/airmon/tm"
influxdb2 "github.com/influxdata/influxdb-client-go/v2"
"go.uber.org/zap"
"strings"
"time"
)

type measurement struct {
Expand Down
5 changes: 3 additions & 2 deletions gateway/influx/influx.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ import (
"context"
"errors"
"flag"
"os"
"time"

"github.com/hg/airmon/logger"
influxdb2 "github.com/influxdata/influxdb-client-go/v2"
influxdb2Api "github.com/influxdata/influxdb-client-go/v2/api"
influxdb2Write "github.com/influxdata/influxdb-client-go/v2/api/write"
"go.uber.org/zap"
"os"
"time"
)

var log = logger.Get(logger.Influx)
Expand Down
5 changes: 3 additions & 2 deletions gateway/kazhydromet/kazhydromet.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
package kazhydromet

import (
"strconv"
"time"

"github.com/hg/airmon/influx"
"github.com/hg/airmon/logger"
"github.com/hg/airmon/net"
"github.com/hg/airmon/storage"
influxdb2 "github.com/influxdata/influxdb-client-go/v2"
"github.com/pkg/errors"
"go.uber.org/zap"
"strconv"
"time"
)

var log = logger.Get(logger.Kazhydromet)
Expand Down
9 changes: 6 additions & 3 deletions gateway/logger/logger.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
package logger

import (
"go.uber.org/zap"
"sync"

"go.uber.org/zap"
)

var mu = sync.Mutex{}
var loggers = make(map[string]*zap.Logger)
var (
mu = sync.Mutex{}
loggers = make(map[string]*zap.Logger)
)

const (
Main = "main"
Expand Down
5 changes: 3 additions & 2 deletions gateway/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,16 @@ package main
import (
"flag"
"fmt"
"os"
"runtime/pprof"

"github.com/hg/airmon/airkaz"
"github.com/hg/airmon/ceb"
"github.com/hg/airmon/influx"
"github.com/hg/airmon/kazhydromet"
"github.com/hg/airmon/logger"
"github.com/hg/airmon/mqtt"
"go.uber.org/zap"
"os"
"runtime/pprof"
)

func main() {
Expand Down
3 changes: 2 additions & 1 deletion gateway/mon/co2.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ package mon

import (
"encoding/json"
"time"

influxdb2 "github.com/influxdata/influxdb-client-go/v2"
influxdb2Write "github.com/influxdata/influxdb-client-go/v2/api/write"
"time"
)

type co2 struct {
Expand Down
3 changes: 2 additions & 1 deletion gateway/mon/pm.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ package mon

import (
"encoding/json"
"time"

influxdb2 "github.com/influxdata/influxdb-client-go/v2"
influxdb2Write "github.com/influxdata/influxdb-client-go/v2/api/write"
"time"
)

type pmConcentration struct {
Expand Down
3 changes: 2 additions & 1 deletion gateway/mon/temperature.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ package mon

import (
"encoding/json"
"time"

influxdb2 "github.com/influxdata/influxdb-client-go/v2"
influxdb2Write "github.com/influxdata/influxdb-client-go/v2/api/write"
"time"
)

type temperature struct {
Expand Down
5 changes: 3 additions & 2 deletions gateway/mqtt/mqtt.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@ package mqtt

import (
"flag"
"os"
"strings"

mqtt "github.com/eclipse/paho.mqtt.golang"
"github.com/hg/airmon/influx"
"github.com/hg/airmon/logger"
"github.com/hg/airmon/mon"
"github.com/pkg/errors"
"go.uber.org/zap"
"os"
"strings"
)

var log = logger.Get(logger.Mqtt)
Expand Down
9 changes: 5 additions & 4 deletions gateway/net/net.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,17 @@ package net
import (
"context"
"encoding/json"
"github.com/hg/airmon/logger"
"github.com/pkg/errors"
"go.uber.org/zap"
"golang.org/x/net/proxy"
"io/ioutil"
"math/rand"
"net"
"net/http"
"net/url"
"time"

"github.com/hg/airmon/logger"
"github.com/pkg/errors"
"go.uber.org/zap"
"golang.org/x/net/proxy"
)

var userAgents = []string{
Expand Down
10 changes: 5 additions & 5 deletions gateway/storage/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ package storage

import (
"encoding/json"
"github.com/hg/airmon/logger"
"go.uber.org/zap"
"io/ioutil"
"os"
"path"

"github.com/hg/airmon/logger"
"go.uber.org/zap"
)

var log = logger.Get(logger.Storage)
Expand All @@ -18,8 +19,7 @@ func getPath(filename string) (string, error) {
}
dir = path.Join(dir, "airmon")

err := os.MkdirAll(dir, 0750)

err := os.MkdirAll(dir, 0o750)
if err != nil {
log.Error("could not create data directory",
zap.String("path", dir),
Expand All @@ -46,7 +46,7 @@ func Save(filename string, data interface{}) error {
return err
}

err = ioutil.WriteFile(fullPath, serialized, 0640)
err = ioutil.WriteFile(fullPath, serialized, 0o640)
if err != nil {
log.Error("could not write file",
zap.String("path", fullPath),
Expand Down
5 changes: 3 additions & 2 deletions gateway/tm/tm.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package tm

import (
"github.com/hg/airmon/logger"
"go.uber.org/zap"
"strings"
"time"

"github.com/hg/airmon/logger"
"go.uber.org/zap"
)

const (
Expand Down

0 comments on commit 693b5e8

Please sign in to comment.