chore(aa): cosmetic.

This commit is contained in:
Alexandre Pujol 2024-05-30 20:56:53 +01:00
parent 4282fb336e
commit 16f30007e7
No known key found for this signature in database
GPG Key ID: C5469996F0DF68EC
3 changed files with 14 additions and 15 deletions

View File

@ -4,7 +4,7 @@
package aa package aa
const PIVOTROOT = "pivot_root" const PIVOTROOT Kind = "pivot_root"
type PivotRoot struct { type PivotRoot struct {
RuleBase RuleBase

View File

@ -7,7 +7,6 @@ package aa
import ( import (
"embed" "embed"
"fmt" "fmt"
"reflect"
"strings" "strings"
"text/template" "text/template"
) )
@ -176,12 +175,12 @@ func generateRequirementsWeights(requirements map[Kind]requirement) map[Kind]map
} }
func join(i any) string { func join(i any) string {
switch reflect.TypeOf(i).Kind() { switch i := i.(type) {
case reflect.Slice: case []string:
return strings.Join(i.([]string), " ") return strings.Join(i, " ")
case reflect.Map: case map[string]string:
res := []string{} res := []string{}
for k, v := range i.(map[string]string) { for k, v := range i {
res = append(res, k+"="+v) res = append(res, k+"="+v)
} }
return strings.Join(res, " ") return strings.Join(res, " ")
@ -191,16 +190,15 @@ func join(i any) string {
} }
func cjoin(i any) string { func cjoin(i any) string {
switch reflect.TypeOf(i).Kind() { switch i := i.(type) {
case reflect.Slice: case []string:
s := i.([]string) if len(i) == 1 {
if len(s) == 1 { return i[0]
return s[0]
} }
return "(" + strings.Join(s, " ") + ")" return "(" + strings.Join(i, " ") + ")"
case reflect.Map: case map[string]string:
res := []string{} res := []string{}
for k, v := range i.(map[string]string) { for k, v := range i {
res = append(res, k+"="+v) res = append(res, k+"="+v)
} }
return "(" + strings.Join(res, " ") + ")" return "(" + strings.Join(res, " ") + ")"

View File

@ -6,6 +6,7 @@ package logs
import ( import (
"os" "os"
"path/filepath"
"reflect" "reflect"
"strings" "strings"
"testing" "testing"