Skip to content

Commit 3499ad5

Browse files
authored
gofmt 1.20 (#139)
1 parent dce549b commit 3499ad5

File tree

7 files changed

+50
-51
lines changed

7 files changed

+50
-51
lines changed

accessors.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ var mapAccessRegex = regexp.MustCompile(mapAccessRegexString)
3737
//
3838
// Get can only operate directly on map[string]interface{} and []interface.
3939
//
40-
// Example
40+
// # Example
4141
//
4242
// To access the title of the third chapter of the second book, do:
4343
//
44-
// o.Get("books[1].chapters[2].title")
44+
// o.Get("books[1].chapters[2].title")
4545
func (m Map) Get(selector string) *Value {
4646
rawObj := access(m, selector, nil, false)
4747
return &Value{data: rawObj}
@@ -52,11 +52,11 @@ func (m Map) Get(selector string) *Value {
5252
//
5353
// Set can only operate directly on map[string]interface{} and []interface
5454
//
55-
// Example
55+
// # Example
5656
//
5757
// To set the title of the third chapter of the second book, do:
5858
//
59-
// o.Set("books[1].chapters[2].title","Time to Go")
59+
// o.Set("books[1].chapters[2].title","Time to Go")
6060
func (m Map) Set(selector string, value interface{}) Map {
6161
access(m, selector, value, true)
6262
return m

codegen/template.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
{4} ({1} and []{1})
2+
{4} ({1} and []{1})
33
*/
44

55
// {4} gets the value as a {1}, returns the optionalDefault

codegen/template_test.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Tests for {4} ({1} and []{1})
2+
Tests for {4} ({1} and []{1})
33
*/
44
func Test{4}(t *testing.T) {
55
val := {1}({2})

doc.go

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,66 @@
11
/*
22
Package objx provides utilities for dealing with maps, slices, JSON and other data.
33
4-
Overview
4+
# Overview
55
66
Objx provides the `objx.Map` type, which is a `map[string]interface{}` that exposes
77
a powerful `Get` method (among others) that allows you to easily and quickly get
88
access to data within the map, without having to worry too much about type assertions,
99
missing data, default values etc.
1010
11-
Pattern
11+
# Pattern
1212
1313
Objx uses a predictable pattern to make access data from within `map[string]interface{}` easy.
1414
Call one of the `objx.` functions to create your `objx.Map` to get going:
1515
16-
m, err := objx.FromJSON(json)
16+
m, err := objx.FromJSON(json)
1717
1818
NOTE: Any methods or functions with the `Must` prefix will panic if something goes wrong,
1919
the rest will be optimistic and try to figure things out without panicking.
2020
2121
Use `Get` to access the value you're interested in. You can use dot and array
2222
notation too:
2323
24-
m.Get("places[0].latlng")
24+
m.Get("places[0].latlng")
2525
2626
Once you have sought the `Value` you're interested in, you can use the `Is*` methods to determine its type.
2727
28-
if m.Get("code").IsStr() { // Your code... }
28+
if m.Get("code").IsStr() { // Your code... }
2929
3030
Or you can just assume the type, and use one of the strong type methods to extract the real value:
3131
32-
m.Get("code").Int()
32+
m.Get("code").Int()
3333
3434
If there's no value there (or if it's the wrong type) then a default value will be returned,
3535
or you can be explicit about the default value.
3636
37-
Get("code").Int(-1)
37+
Get("code").Int(-1)
3838
3939
If you're dealing with a slice of data as a value, Objx provides many useful methods for iterating,
4040
manipulating and selecting that data. You can find out more by exploring the index below.
4141
42-
Reading data
42+
# Reading data
4343
4444
A simple example of how to use Objx:
4545
46-
// Use MustFromJSON to make an objx.Map from some JSON
47-
m := objx.MustFromJSON(`{"name": "Mat", "age": 30}`)
46+
// Use MustFromJSON to make an objx.Map from some JSON
47+
m := objx.MustFromJSON(`{"name": "Mat", "age": 30}`)
4848
49-
// Get the details
50-
name := m.Get("name").Str()
51-
age := m.Get("age").Int()
49+
// Get the details
50+
name := m.Get("name").Str()
51+
age := m.Get("age").Int()
5252
53-
// Get their nickname (or use their name if they don't have one)
54-
nickname := m.Get("nickname").Str(name)
53+
// Get their nickname (or use their name if they don't have one)
54+
nickname := m.Get("nickname").Str(name)
5555
56-
Ranging
56+
# Ranging
5757
5858
Since `objx.Map` is a `map[string]interface{}` you can treat it as such.
5959
For example, to `range` the data, do what you would expect:
6060
61-
m := objx.MustFromJSON(json)
62-
for key, value := range m {
63-
// Your code...
64-
}
61+
m := objx.MustFromJSON(json)
62+
for key, value := range m {
63+
// Your code...
64+
}
6565
*/
6666
package objx

map.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,17 +47,16 @@ func New(data interface{}) Map {
4747
//
4848
// The arguments follow a key, value pattern.
4949
//
50-
//
5150
// Returns nil if any key argument is non-string or if there are an odd number of arguments.
5251
//
53-
// Example
52+
// # Example
5453
//
5554
// To easily create Maps:
5655
//
57-
// m := objx.MSI("name", "Mat", "age", 29, "subobj", objx.MSI("active", true))
56+
// m := objx.MSI("name", "Mat", "age", 29, "subobj", objx.MSI("active", true))
5857
//
59-
// // creates an Map equivalent to
60-
// m := objx.Map{"name": "Mat", "age": 29, "subobj": objx.Map{"active": true}}
58+
// // creates an Map equivalent to
59+
// m := objx.Map{"name": "Mat", "age": 29, "subobj": objx.Map{"active": true}}
6160
func MSI(keyAndValuePairs ...interface{}) Map {
6261
newMap := Map{}
6362
keyAndValuePairsLen := len(keyAndValuePairs)

type_specific_codegen_test.go

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
)
1010

1111
/*
12-
Tests for Inter (interface{} and []interface{})
12+
Tests for Inter (interface{} and []interface{})
1313
*/
1414
func TestInter(t *testing.T) {
1515
val := interface{}("something")
@@ -130,7 +130,7 @@ func TestCollectInter(t *testing.T) {
130130
}
131131

132132
/*
133-
Tests for Bool (bool and []bool)
133+
Tests for Bool (bool and []bool)
134134
*/
135135
func TestBool(t *testing.T) {
136136
val := bool(true)
@@ -251,7 +251,7 @@ func TestCollectBool(t *testing.T) {
251251
}
252252

253253
/*
254-
Tests for Str (string and []string)
254+
Tests for Str (string and []string)
255255
*/
256256
func TestStr(t *testing.T) {
257257
val := string("hello")
@@ -372,7 +372,7 @@ func TestCollectStr(t *testing.T) {
372372
}
373373

374374
/*
375-
Tests for Int (int and []int)
375+
Tests for Int (int and []int)
376376
*/
377377
func TestInt(t *testing.T) {
378378
val := int(1)
@@ -493,7 +493,7 @@ func TestCollectInt(t *testing.T) {
493493
}
494494

495495
/*
496-
Tests for Int8 (int8 and []int8)
496+
Tests for Int8 (int8 and []int8)
497497
*/
498498
func TestInt8(t *testing.T) {
499499
val := int8(1)
@@ -614,7 +614,7 @@ func TestCollectInt8(t *testing.T) {
614614
}
615615

616616
/*
617-
Tests for Int16 (int16 and []int16)
617+
Tests for Int16 (int16 and []int16)
618618
*/
619619
func TestInt16(t *testing.T) {
620620
val := int16(1)
@@ -735,7 +735,7 @@ func TestCollectInt16(t *testing.T) {
735735
}
736736

737737
/*
738-
Tests for Int32 (int32 and []int32)
738+
Tests for Int32 (int32 and []int32)
739739
*/
740740
func TestInt32(t *testing.T) {
741741
val := int32(1)
@@ -856,7 +856,7 @@ func TestCollectInt32(t *testing.T) {
856856
}
857857

858858
/*
859-
Tests for Int64 (int64 and []int64)
859+
Tests for Int64 (int64 and []int64)
860860
*/
861861
func TestInt64(t *testing.T) {
862862
val := int64(1)
@@ -977,7 +977,7 @@ func TestCollectInt64(t *testing.T) {
977977
}
978978

979979
/*
980-
Tests for Uint (uint and []uint)
980+
Tests for Uint (uint and []uint)
981981
*/
982982
func TestUint(t *testing.T) {
983983
val := uint(1)
@@ -1098,7 +1098,7 @@ func TestCollectUint(t *testing.T) {
10981098
}
10991099

11001100
/*
1101-
Tests for Uint8 (uint8 and []uint8)
1101+
Tests for Uint8 (uint8 and []uint8)
11021102
*/
11031103
func TestUint8(t *testing.T) {
11041104
val := uint8(1)
@@ -1219,7 +1219,7 @@ func TestCollectUint8(t *testing.T) {
12191219
}
12201220

12211221
/*
1222-
Tests for Uint16 (uint16 and []uint16)
1222+
Tests for Uint16 (uint16 and []uint16)
12231223
*/
12241224
func TestUint16(t *testing.T) {
12251225
val := uint16(1)
@@ -1340,7 +1340,7 @@ func TestCollectUint16(t *testing.T) {
13401340
}
13411341

13421342
/*
1343-
Tests for Uint32 (uint32 and []uint32)
1343+
Tests for Uint32 (uint32 and []uint32)
13441344
*/
13451345
func TestUint32(t *testing.T) {
13461346
val := uint32(1)
@@ -1461,7 +1461,7 @@ func TestCollectUint32(t *testing.T) {
14611461
}
14621462

14631463
/*
1464-
Tests for Uint64 (uint64 and []uint64)
1464+
Tests for Uint64 (uint64 and []uint64)
14651465
*/
14661466
func TestUint64(t *testing.T) {
14671467
val := uint64(1)
@@ -1582,7 +1582,7 @@ func TestCollectUint64(t *testing.T) {
15821582
}
15831583

15841584
/*
1585-
Tests for Uintptr (uintptr and []uintptr)
1585+
Tests for Uintptr (uintptr and []uintptr)
15861586
*/
15871587
func TestUintptr(t *testing.T) {
15881588
val := uintptr(1)
@@ -1703,7 +1703,7 @@ func TestCollectUintptr(t *testing.T) {
17031703
}
17041704

17051705
/*
1706-
Tests for Float32 (float32 and []float32)
1706+
Tests for Float32 (float32 and []float32)
17071707
*/
17081708
func TestFloat32(t *testing.T) {
17091709
val := float32(1)
@@ -1824,7 +1824,7 @@ func TestCollectFloat32(t *testing.T) {
18241824
}
18251825

18261826
/*
1827-
Tests for Float64 (float64 and []float64)
1827+
Tests for Float64 (float64 and []float64)
18281828
*/
18291829
func TestFloat64(t *testing.T) {
18301830
val := float64(1)
@@ -1945,7 +1945,7 @@ func TestCollectFloat64(t *testing.T) {
19451945
}
19461946

19471947
/*
1948-
Tests for Complex64 (complex64 and []complex64)
1948+
Tests for Complex64 (complex64 and []complex64)
19491949
*/
19501950
func TestComplex64(t *testing.T) {
19511951
val := complex64(1)
@@ -2066,7 +2066,7 @@ func TestCollectComplex64(t *testing.T) {
20662066
}
20672067

20682068
/*
2069-
Tests for Complex128 (complex128 and []complex128)
2069+
Tests for Complex128 (complex128 and []complex128)
20702070
*/
20712071
func TestComplex128(t *testing.T) {
20722072
val := complex128(1)

type_specific_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
)
1010

1111
/*
12-
Tests for MSI (map[string]interface{} and []map[string]interface{})
12+
Tests for MSI (map[string]interface{} and []map[string]interface{})
1313
*/
1414
func TestMSI(t *testing.T) {
1515
val := map[string]interface{}(map[string]interface{}{"name": "Tyler"})
@@ -232,7 +232,7 @@ func TestCollectMSI2(t *testing.T) {
232232
}
233233

234234
/*
235-
Tests for ObjxMap ((objx.Map) and [](objx.Map))
235+
Tests for ObjxMap ((objx.Map) and [](objx.Map))
236236
*/
237237
func TestObjxMap(t *testing.T) {
238238
val := (objx.Map)(objx.New(1))

0 commit comments

Comments
 (0)