Skip to content

Commit f532d34

Browse files
committed
lexicon: have catalog constructors return ptr values
1 parent ea3d39e commit f532d34

File tree

6 files changed

+11
-11
lines changed

6 files changed

+11
-11
lines changed

atproto/lexicon/catalog.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ type BaseCatalog struct {
2424
}
2525

2626
// Creates a new empty BaseCatalog
27-
func NewBaseCatalog() BaseCatalog {
28-
return BaseCatalog{
27+
func NewBaseCatalog() *BaseCatalog {
28+
return &BaseCatalog{
2929
schemas: make(map[string]Schema),
3030
}
3131
}

atproto/lexicon/cmd/lextool/net.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ func runValidateRecord(ctx context.Context, cmd *cli.Command) error {
7373
}
7474

7575
slog.Info("validating", "did", ident.DID.String(), "collection", aturi.Collection().String(), "rkey", aturi.RecordKey().String())
76-
err = lexicon.ValidateRecord(&cat, record, aturi.Collection().String(), lexicon.LenientMode)
76+
err = lexicon.ValidateRecord(cat, record, aturi.Collection().String(), lexicon.LenientMode)
7777
if err != nil {
7878
return err
7979
}

atproto/lexicon/examples_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func ExampleValidateRecord() {
3232
panic("failed to parse record JSON")
3333
}
3434

35-
if err := ValidateRecord(&cat, recordData, "example.lexicon.record", 0); err != nil {
35+
if err := ValidateRecord(cat, recordData, "example.lexicon.record", 0); err != nil {
3636
fmt.Printf("Schema validation failed: %v\n", err)
3737
} else {
3838
fmt.Println("Success!")

atproto/lexicon/interop_record_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ func TestInteropRecordValid(t *testing.T) {
4949
t.Fatal(err)
5050
}
5151

52-
assert.NoError(ValidateRecord(&cat, d, "example.lexicon.record", 0))
52+
assert.NoError(ValidateRecord(cat, d, "example.lexicon.record", 0))
5353
}
5454
}
5555

@@ -83,7 +83,7 @@ func TestInteropRecordInvalid(t *testing.T) {
8383
if err != nil {
8484
t.Fatal(err)
8585
}
86-
err = ValidateRecord(&cat, d, "example.lexicon.record", 0)
86+
err = ValidateRecord(cat, d, "example.lexicon.record", 0)
8787
if err == nil {
8888
fmt.Println(" FAIL")
8989
}

atproto/lexicon/resolving_catalog.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ import (
1212

1313
// Catalog which supplements an in-memory BaseCatalog with live resolution from the network
1414
type ResolvingCatalog struct {
15-
Base BaseCatalog
15+
Base *BaseCatalog
1616
Directory identity.Directory
1717
}
1818

19-
func NewResolvingCatalog() ResolvingCatalog {
20-
return ResolvingCatalog{
19+
func NewResolvingCatalog() *ResolvingCatalog {
20+
return &ResolvingCatalog{
2121
Base: NewBaseCatalog(),
2222
Directory: identity.DefaultDirectory(),
2323
}

atproto/lexicon/validation_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ func TestBasicCatalog(t *testing.T) {
1919
t.Fatal(err)
2020
}
2121
assert.NoError(validateData(
22-
&cat,
22+
cat,
2323
def.Def,
2424
map[string]any{
2525
"cid": "bafybeigdyrzt5sfp7udm7hu76uh7y26nf3efuylqabf3oclgtqy55fbzdi",
@@ -33,7 +33,7 @@ func TestBasicCatalog(t *testing.T) {
3333
))
3434

3535
assert.Error(validateData(
36-
&cat,
36+
cat,
3737
def.Def,
3838
map[string]any{
3939
"cid": "bafybeigdyrzt5sfp7udm7hu76uh7y26nf3efuylqabf3oclgtqy55fbzdi",

0 commit comments

Comments
 (0)