Skip to content

Commit

Permalink
Fix typos in comments and function names (#129)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandear committed Nov 22, 2022
1 parent c0315e5 commit 3ede46d
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
16 changes: 8 additions & 8 deletions accessors.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@ const (
// For example, `location.address.city`
PathSeparator string = "."

// arrayAccesRegexString is the regex used to extract the array number
// arrayAccessRegexString is the regex used to extract the array number
// from the access path
arrayAccesRegexString = `^(.+)\[([0-9]+)\]$`
arrayAccessRegexString = `^(.+)\[([0-9]+)\]$`

// mapAccessRegexString is the regex used to extract the map key
// from the access path
mapAccessRegexString = `^([^\[]*)\[([^\]]+)\](.*)$`
)

// arrayAccesRegex is the compiled arrayAccesRegexString
var arrayAccesRegex = regexp.MustCompile(arrayAccesRegexString)
// arrayAccessRegex is the compiled arrayAccessRegexString
var arrayAccessRegex = regexp.MustCompile(arrayAccessRegexString)

// mapAccessRegex is the compiled mapAccessRegexString
var mapAccessRegex = regexp.MustCompile(mapAccessRegexString)
Expand Down Expand Up @@ -62,16 +62,16 @@ func (m Map) Set(selector string, value interface{}) Map {
return m
}

// getIndex returns the index, which is hold in s by two braches.
// It also returns s withour the index part, e.g. name[1] will return (1, name).
// getIndex returns the index, which is hold in s by two branches.
// It also returns s without the index part, e.g. name[1] will return (1, name).
// If no index is found, -1 is returned
func getIndex(s string) (int, string) {
arrayMatches := arrayAccesRegex.FindStringSubmatch(s)
arrayMatches := arrayAccessRegex.FindStringSubmatch(s)
if len(arrayMatches) > 0 {
// Get the key into the map
selector := arrayMatches[1]
// Get the index into the array at the key
// We know this cannt fail because arrayMatches[2] is an int for sure
// We know this can't fail because arrayMatches[2] is an int for sure
index, _ := strconv.Atoi(arrayMatches[2])
return index, selector
}
Expand Down
4 changes: 2 additions & 2 deletions conversions.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
const SignatureSeparator = "_"

// URLValuesSliceKeySuffix is the character that is used to
// specify a suffic for slices parsed by URLValues.
// specify a suffix for slices parsed by URLValues.
// If the suffix is set to "[i]", then the index of the slice
// is used in place of i
// Ex: Suffix "[]" would have the form a[]=b&a[]=c
Expand All @@ -30,7 +30,7 @@ const (
)

// SetURLValuesSliceKeySuffix sets the character that is used to
// specify a suffic for slices parsed by URLValues.
// specify a suffix for slices parsed by URLValues.
// If the suffix is set to "[i]", then the index of the slice
// is used in place of i
// Ex: Suffix "[]" would have the form a[]=b&a[]=c
Expand Down
4 changes: 2 additions & 2 deletions doc.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Objx - Go package for dealing with maps, slices, JSON and other data.
Package objx provides utilities for dealing with maps, slices, JSON and other data.
Overview
Expand All @@ -10,7 +10,7 @@ missing data, default values etc.
Pattern
Objx uses a preditable pattern to make access data from within `map[string]interface{}` easy.
Objx uses a predictable pattern to make access data from within `map[string]interface{}` easy.
Call one of the `objx.` functions to create your `objx.Map` to get going:
m, err := objx.FromJSON(json)
Expand Down
2 changes: 1 addition & 1 deletion map_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func TestMapCreation(t *testing.T) {
assert.Nil(t, o)
}

func TestMapValure(t *testing.T) {
func TestMapValue(t *testing.T) {
m := objx.Map{
"a": 1,
}
Expand Down
2 changes: 1 addition & 1 deletion type_specific_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ func TestIsObjxMapSlice(t *testing.T) {
assert.True(t, o.Has("d"))
assert.True(t, o.Get("d").IsObjxMapSlice())

//Valid json but not MSI slice
// Valid json but not MSI slice
o = objx.MustFromJSON(`{"d":[{"author":"abc"},[1]]}`)
assert.True(t, o.Has("d"))
assert.False(t, o.Get("d").IsObjxMapSlice())
Expand Down

0 comments on commit 3ede46d

Please sign in to comment.