diff --git a/http/good_temp.go b/http/good_temp.go index bce32b5..1fde50a 100644 --- a/http/good_temp.go +++ b/http/good_temp.go @@ -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 diff --git a/lib/database/database.go b/lib/database/database.go index 3d33ce1..66b9142 100644 --- a/lib/database/database.go +++ b/lib/database/database.go @@ -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 diff --git a/lib/http/io.go b/lib/http/io.go index a9945d1..e6eb562 100644 --- a/lib/http/io.go +++ b/lib/http/io.go @@ -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") diff --git a/lib/worker/worker_test.go b/lib/worker/worker_test.go index e551ad9..0ddabf2 100644 --- a/lib/worker/worker_test.go +++ b/lib/worker/worker_test.go @@ -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() diff --git a/models/config.go b/models/config.go index 73a4c32..b7ab531 100644 --- a/models/config.go +++ b/models/config.go @@ -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 diff --git a/models/duration.go b/models/duration.go index 3aa5a5d..1b91c0c 100644 --- a/models/duration.go +++ b/models/duration.go @@ -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) } diff --git a/models/duration_test.go b/models/duration_test.go index e909052..3a914a8 100644 --- a/models/duration_test.go +++ b/models/duration_test.go @@ -8,7 +8,6 @@ import ( "github.com/stretchr/testify/assert" ) - // Function to test UnmarshalTOML() func TestDuration(t *testing.T) { assert := assert.New(t) diff --git a/models/good.go b/models/good.go index 0a883ad..df725ce 100644 --- a/models/good.go +++ b/models/good.go @@ -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:"-"` diff --git a/models/testdata/config_panic.conf b/models/testdata/config_panic.conf index 40142d0..4a7e54f 100644 --- a/models/testdata/config_panic.conf +++ b/models/testdata/config_panic.conf @@ -1 +1,2 @@ -blub +invalid structur of a config file +(should not be able unmarshal to the config struct ) diff --git a/runtime/auth.go b/runtime/auth.go index e0461ee..e4442e6 100644 --- a/runtime/auth.go +++ b/runtime/auth.go @@ -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 diff --git a/runtime/productcache.go b/runtime/productcache.go index 00801bc..0d64abc 100644 --- a/runtime/productcache.go +++ b/runtime/productcache.go @@ -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)