Go fmt'ed files

This commit is contained in:
mariusor 2021-11-12 18:26:50 +01:00
parent bd0dbddb26
commit 5064eea988
22 changed files with 88 additions and 88 deletions

View file

@ -785,7 +785,7 @@ func (a Activity) GobEncode() ([]byte, error) {
func (a *Activity) GobDecode([]byte) error {
return errors.New(fmt.Sprintf("GobDecode is not implemented for %T", *a))
}
*/
*/
// Equals verifies if our receiver Object is equals with the "with" Object
func (a Activity) Equals(with Item) bool {

View file

@ -245,7 +245,7 @@ func (a Actor) GobEncode() ([]byte, error) {
func (a *Actor) GobDecode([]byte) error {
return errors.New(fmt.Sprintf("GobDecode is not implemented for %T", *a))
}
*/
*/
type (
// Application describes a software application.

View file

@ -376,8 +376,8 @@ func TestPublicKey_MarshalJSON(t *testing.T) {
}
func assertPersonWithTesting(fn canErrorFunc, expected Item) WithActorFn {
return func (p *Person) error {
if !assertDeepEquals(fn, p , expected) {
return func(p *Person) error {
if !assertDeepEquals(fn, p, expected) {
return fmt.Errorf("not equal")
}
return nil

View file

@ -288,7 +288,7 @@ func (c Collection) GobEncode() ([]byte, error) {
func (c *Collection) GobDecode([]byte) error {
return errors.New(fmt.Sprintf("GobDecode is not implemented for %T", *c))
}
*/
*/
// ToCollection
func ToCollection(it Item) (*Collection, error) {

View file

@ -252,7 +252,7 @@ func (c CollectionPage) GobEncode() ([]byte, error) {
func (c *CollectionPage) GobDecode([]byte) error {
return errors.New(fmt.Sprintf("GobDecode is not implemented for %T", *c))
}
*/
*/
// CollectionNew initializes a new CollectionPage
func CollectionPageNew(parent CollectionInterface) *CollectionPage {

View file

@ -136,9 +136,12 @@ func deepValueEqual(t canErrorFunc, v1, v2 reflect.Value, visited map[visit]bool
case reflect.Struct:
for i, n := 0, v1.NumField(); i < n; i++ {
var (
f1 = v1.Field(i); f2 = v2.Field(i)
n1 = v1.Type().Field(i).Name; n2 = v2.Type().Field(i).Name
t1 = f1.Type().Name(); t2 = f2.Type().Name()
f1 = v1.Field(i)
f2 = v2.Field(i)
n1 = v1.Type().Field(i).Name
n2 = v2.Type().Field(i).Name
t1 = f1.Type().Name()
t2 = f2.Type().Name()
)
if !deepValueEqual(t, v1.Field(i), v2.Field(i), visited, depth+1) {
t("Struct fields at pos %d %s[%s] and %s[%s] are not deeply equal", i, n1, t1, n2, t2)

View file

@ -18,7 +18,7 @@ type gobEncoder struct {
enc *gob.Encoder
}
func (e *gobEncoder) encode (it Item) ([]byte, error) {
func (e *gobEncoder) encode(it Item) ([]byte, error) {
err := e.enc.Encode(it)
if err != nil {
return nil, err
@ -26,7 +26,6 @@ func (e *gobEncoder) encode (it Item) ([]byte, error) {
return e.w.Bytes(), nil
}
//// GobEncode
//func GobEncode(it Item) ([]byte, error) {
// w := bytes.NewBuffer(make([]byte, 0))
@ -45,24 +44,24 @@ func (e *gobEncoder) writeIRIProp(i IRI) error {
return e.enc.Encode(i.String())
}
func (e *gobEncoder) writeGobProp (p string, b []byte) bool {
func (e *gobEncoder) writeGobProp(p string, b []byte) bool {
c, _ := e.w.Write([]byte(p))
d, _ := e.w.Write(b)
return c+d > 0
}
func (e *gobEncoder)writeItemGobProp (p string, it Item) bool {
func (e *gobEncoder) writeItemGobProp(p string, it Item) bool {
return true
}
func (e *gobEncoder)writeNaturalLanguageGobProp (p string, v NaturalLanguageValues) bool {
func (e *gobEncoder) writeNaturalLanguageGobProp(p string, v NaturalLanguageValues) bool {
return true
}
func (e *gobEncoder)writeIRIGobProp (p string, i LinkOrIRI) bool {
func (e *gobEncoder) writeIRIGobProp(p string, i LinkOrIRI) bool {
return true
}
func (e *gobEncoder)writeTimeGobProp (p string, t time.Time) bool {
func (e *gobEncoder) writeTimeGobProp(p string, t time.Time) bool {
return true
}
func (e *gobEncoder)writeDurationGobProp (p string, d time.Duration) bool {
func (e *gobEncoder) writeDurationGobProp(p string, d time.Duration) bool {
return true
}
@ -170,4 +169,4 @@ func (e *gobEncoder) writeObjectGobValue(o Object) (bool, error) {
}
return notEmpty, nil
}
*/
*/

View file

@ -25,10 +25,10 @@ func TestMarshalGob(t *testing.T) {
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
buf := bytes.NewBuffer(make([]byte,0))
buf := bytes.NewBuffer(make([]byte, 0))
err := gob.NewEncoder(buf).Encode(tt.it)
if !errors.Is(err, tt.wantErr){
if !errors.Is(err, tt.wantErr) {
t.Errorf("MarshalGob() error = %s, wantErr %v", err, tt.wantErr)
return
}

View file

@ -6,8 +6,8 @@ import (
)
func assertObjectWithTesting(fn canErrorFunc, expected Item) WithObjectFn {
return func (p *Object) error {
if !assertDeepEquals(fn, p , expected) {
return func(p *Object) error {
if !assertDeepEquals(fn, p, expected) {
return fmt.Errorf("not equal")
}
return nil
@ -69,8 +69,8 @@ func TestOnObject(t *testing.T) {
}
func assertActivityWithTesting(fn canErrorFunc, expected Item) WithActivityFn {
return func (p *Activity) error {
if !assertDeepEquals(fn, p , expected) {
return func(p *Activity) error {
if !assertDeepEquals(fn, p, expected) {
return fmt.Errorf("not equal")
}
return nil
@ -132,8 +132,8 @@ func TestOnActivity(t *testing.T) {
}
func assertIntransitiveActivityWithTesting(fn canErrorFunc, expected Item) WithIntransitiveActivityFn {
return func (p *IntransitiveActivity) error {
if !assertDeepEquals(fn, p , expected) {
return func(p *IntransitiveActivity) error {
if !assertDeepEquals(fn, p, expected) {
return fmt.Errorf("not equal")
}
return nil
@ -195,8 +195,8 @@ func TestOnIntransitiveActivity(t *testing.T) {
}
func assertQuestionWithTesting(fn canErrorFunc, expected Item) WithQuestionFn {
return func (p *Question) error {
if !assertDeepEquals(fn, p , expected) {
return func(p *Question) error {
if !assertDeepEquals(fn, p, expected) {
return fmt.Errorf("not equal")
}
return nil

View file

@ -217,7 +217,7 @@ func (i IntransitiveActivity) GobEncode() ([]byte, error) {
func (i *IntransitiveActivity) GobDecode([]byte) error {
return errors.New(fmt.Sprintf("GobDecode is not implemented for %T", *i))
}
*/
*/
// IntransitiveActivityNew initializes a intransitive activity
func IntransitiveActivityNew(id ID, typ ActivityVocabularyType) *IntransitiveActivity {

2
iri.go
View file

@ -90,7 +90,7 @@ func (i IRI) GobEncode() ([]byte, error) {
func (i *IRI) GobDecode([]byte) error {
return errors.New(fmt.Sprintf("GobDecode is not implemented for %T", *i))
}
*/
*/
// AddPath concatenates el elements as a path to i
func (i IRI) AddPath(el ...string) IRI {

View file

@ -51,7 +51,7 @@ func ItemsEqual(it, with Item) bool {
}
if it.IsObject() {
if ActivityTypes.Contains(with.GetType()) {
OnActivity(it, func(i*Activity) error {
OnActivity(it, func(i *Activity) error {
result = i.Equals(with)
return nil
})

View file

@ -132,4 +132,4 @@ func (l Link) GobEncode() ([]byte, error) {
func (l *Link) GobDecode([]byte) error {
return errors.New(fmt.Sprintf("GobDecode is not implemented for %T", *l))
}
*/
*/

View file

@ -473,7 +473,6 @@ func TestSource_UnmarshalJSON(t *testing.T) {
func TestGetAPSource(t *testing.T) {
data := []byte(`{"source": {"content": "test", "mediaType": "text/plain" }}`)
par := fastjson.Parser{}
val, _ := par.ParseBytes(data)
a := GetAPSource(val)

View file

@ -46,8 +46,8 @@ func TestPlace_Clean(t *testing.T) {
}
func assertPlaceWithTesting(fn canErrorFunc, expected *Place) withPlaceFn {
return func (p *Place) error {
if !assertDeepEquals(fn, p , expected) {
return func(p *Place) error {
if !assertDeepEquals(fn, p, expected) {
return fmt.Errorf("not equal")
}
return nil
@ -69,22 +69,22 @@ func TestOnPlace(t *testing.T) {
}{
{
name: "single",
args: args{ testPlace, assertPlaceWithTesting },
args: args{testPlace, assertPlaceWithTesting},
wantErr: false,
},
{
name: "single fails",
args: args{ Place{ID: "https://not-equals"}, assertPlaceWithTesting },
args: args{Place{ID: "https://not-equals"}, assertPlaceWithTesting},
wantErr: true,
},
{
name: "collectionOfPlaces",
args: args{ItemCollection{testPlace, testPlace}, assertPlaceWithTesting },
args: args{ItemCollection{testPlace, testPlace}, assertPlaceWithTesting},
wantErr: false,
},
{
name: "collectionOfPlaces fails",
args: args{ ItemCollection{testPlace, Place{ID: "https://not-equals"}}, assertPlaceWithTesting },
args: args{ItemCollection{testPlace, Place{ID: "https://not-equals"}}, assertPlaceWithTesting},
wantErr: true,
},
}

View file

@ -46,8 +46,8 @@ func TestProfile_Clean(t *testing.T) {
}
func assertProfileWithTesting(fn canErrorFunc, expected *Profile) withProfileFn {
return func (p *Profile) error {
if !assertDeepEquals(fn, p , expected) {
return func(p *Profile) error {
if !assertDeepEquals(fn, p, expected) {
return fmt.Errorf("not equal")
}
return nil

View file

@ -55,7 +55,6 @@ func TestQuestion_GetType(t *testing.T) {
}
}
func TestToQuestion(t *testing.T) {
var it Item
act := QuestionNew("test")

View file

@ -37,8 +37,8 @@ func TestTombstone_Clean(t *testing.T) {
t.Skipf("TODO")
}
func assertTombstoneWithTesting(fn canErrorFunc, expected *Tombstone) withTombstoneFn {
return func (p *Tombstone) error {
if !assertDeepEquals(fn, p , expected) {
return func(p *Tombstone) error {
if !assertDeepEquals(fn, p, expected) {
return fmt.Errorf("not equal")
}
return nil