format by linter
This commit is contained in:
parent
99d62fcb47
commit
1e84ad95d6
|
@ -21,7 +21,7 @@ func tempPercent(value, max int) int {
|
|||
|
||||
// Function to calculate a partial radius, depending on a percentage value
|
||||
func tempProcessRadius(value, max, radius int) float64 {
|
||||
return (1 - float64(value) / float64(max)) * float64(radius) * 2 * 3.14
|
||||
return (1 - float64(value)/float64(max)) * float64(radius) * 2 * 3.14
|
||||
}
|
||||
|
||||
// Function to get the SVG, that shows the availability with a traffic light food labeling system for a given good
|
||||
|
|
|
@ -24,13 +24,13 @@ var (
|
|||
// Configuration of the database connection
|
||||
type Config struct {
|
||||
// Type of the database (currently supports sqlite and postgres)
|
||||
Type string
|
||||
Type string
|
||||
// Connection configuration
|
||||
Connection string
|
||||
Connection string
|
||||
// Create another connection for reading only
|
||||
ReadConnection string
|
||||
// Enable logging of the generated sql string
|
||||
Logging bool
|
||||
Logging bool
|
||||
}
|
||||
|
||||
// Function to open a database and set the given configuration
|
||||
|
|
|
@ -22,7 +22,7 @@ func Read(r *http.Request, to interface{}) (err error) {
|
|||
func Write(w http.ResponseWriter, data interface{}) {
|
||||
js, err := json.Marshal(data)
|
||||
if err != nil {
|
||||
http.Error(w, "failed to encode response: " + err.Error(), http.StatusInternalServerError)
|
||||
http.Error(w, "failed to encode response: "+err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
|
|
|
@ -14,7 +14,7 @@ func TestWorker(t *testing.T) {
|
|||
|
||||
runtime := 0
|
||||
|
||||
w := NewWorker(time.Duration(5) * time.Millisecond, func() {
|
||||
w := NewWorker(time.Duration(5)*time.Millisecond, func() {
|
||||
runtime = runtime + 1
|
||||
})
|
||||
go w.Start()
|
||||
|
|
|
@ -13,27 +13,27 @@ import (
|
|||
// Config file for this daemon (more information at the config_example.conf in this git repository)
|
||||
type Config struct {
|
||||
// address under which the api and static content of the webserver runs
|
||||
WebserverBind string `toml:"webserver_bind"`
|
||||
WebserverBind string `toml:"webserver_bind"`
|
||||
|
||||
// path to deliver static content
|
||||
Webroot string `toml:"webroot"`
|
||||
Webroot string `toml:"webroot"`
|
||||
|
||||
Database database.Config `toml:"database"`
|
||||
GoodRelease GoodReleaseConfig `toml:"good_release"`
|
||||
CacheClean CacheWorkerConfig `toml:"cache_clean"`
|
||||
Database database.Config `toml:"database"`
|
||||
GoodRelease GoodReleaseConfig `toml:"good_release"`
|
||||
CacheClean CacheWorkerConfig `toml:"cache_clean"`
|
||||
|
||||
// path to the SVG image templates to show the availability and freshness
|
||||
// of a given good with a traffic light food labeling system
|
||||
GoodAvailabilityTemplate string `toml:"good_availablity_template"`
|
||||
GoodFreshnessTemplate string `toml:"good_freshness_template"`
|
||||
|
||||
FouledDeleter Duration `toml:"fouled_deleted"`
|
||||
FouledDeleter Duration `toml:"fouled_deleted"`
|
||||
|
||||
// URLs to other microservices, which this service uses
|
||||
MicroserviceDependencies struct {
|
||||
Product string `toml:"product"`
|
||||
Permission string `toml:"permission"`
|
||||
} `toml:"microservice_dependencies"`
|
||||
Product string `toml:"product"`
|
||||
Permission string `toml:"permission"`
|
||||
} `toml:"microservice_dependencies"`
|
||||
}
|
||||
|
||||
// Configuration of the Worker to clean the cache from values of other microservice
|
||||
|
|
|
@ -28,8 +28,8 @@ func (d *Duration) UnmarshalTOML(dataInterface interface{}) error {
|
|||
return fmt.Errorf("invalid duration: \"%s\"", data)
|
||||
}
|
||||
|
||||
unit := data[len(data) - 1]
|
||||
value, err := strconv.Atoi(string(data[:len(data) - 1]))
|
||||
unit := data[len(data)-1]
|
||||
value, err := strconv.Atoi(string(data[:len(data)-1]))
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to parse duration %s: %s", data, err)
|
||||
}
|
||||
|
|
|
@ -8,7 +8,6 @@ import (
|
|||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
|
||||
// Function to test UnmarshalTOML()
|
||||
func TestDuration(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
|
|
|
@ -12,16 +12,16 @@ import (
|
|||
|
||||
// Type of goods managed in this stock microservice
|
||||
type Good struct {
|
||||
ID int64 `json:"id"`
|
||||
ProductID int64 `json:"product_id"`
|
||||
Position string `json:"position"`
|
||||
Comment string `json:"comment"`
|
||||
FouledAt *time.Time `json:"fouled_at"`
|
||||
ID int64 `json:"id"`
|
||||
ProductID int64 `json:"product_id"`
|
||||
Position string `json:"position"`
|
||||
Comment string `json:"comment"`
|
||||
FouledAt *time.Time `json:"fouled_at"`
|
||||
|
||||
RecievedAt *time.Time `sql:"default:current_timestamp" json:"recieved_at"`
|
||||
RecievedAt *time.Time `sql:"default:current_timestamp" json:"recieved_at"`
|
||||
// Make it temporary unusable
|
||||
LockedAt *time.Time `json:"-"`
|
||||
LockedSecret string `json:"-"`
|
||||
LockedAt *time.Time `json:"-"`
|
||||
LockedSecret string `json:"-"`
|
||||
// Make it unusable
|
||||
DeletedAt *time.Time `json:"-"`
|
||||
ManuelleDelete bool `json:"-"`
|
||||
|
|
|
@ -1 +1,2 @@
|
|||
blub
|
||||
invalid structur of a config file
|
||||
(should not be able unmarshal to the config struct )
|
||||
|
|
|
@ -6,8 +6,9 @@ import (
|
|||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/genofire/hs_master-kss-monolith/lib/log"
|
||||
"sync"
|
||||
|
||||
"github.com/genofire/hs_master-kss-monolith/lib/log"
|
||||
)
|
||||
|
||||
// URL to the microservice, which manages permissions
|
||||
|
|
|
@ -6,8 +6,9 @@ import (
|
|||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/genofire/hs_master-kss-monolith/lib/log"
|
||||
"sync"
|
||||
|
||||
"github.com/genofire/hs_master-kss-monolith/lib/log"
|
||||
)
|
||||
|
||||
// URL to the microservice which manages the products (product catalogue)
|
||||
|
|
Reference in New Issue