Supports for slices in mapuitl.go

This issue has been created since 2021-07-22.

I've been seeing and developing an improvement so that the GetByPath function supports access to slice structures.

I added the following tests in TestGetByPath and they pass successfully.

        //...

        v, ok = maputil.GetByPath("key2", mp)
	assert.True(t, ok)
	assert.Equal(t, mp["key2"], v)

	v, ok = maputil.GetByPath("key2.0", mp)
	assert.True(t, ok)
	assert.Equal(t, "sv1", v)

	v, ok = maputil.GetByPath("key2.1", mp)
	assert.True(t, ok)
	assert.Equal(t, "sv2", v)

	v, ok = maputil.GetByPath("key4.0", mp)
	assert.True(t, ok)
	assert.Equal(t, 1, v)

	v, ok = maputil.GetByPath("key4.1", mp)
	assert.True(t, ok)
	assert.Equal(t, 2, v)

	v, ok = maputil.GetByPath("key5.0", mp)
	assert.True(t, ok)
	assert.Equal(t, 1, v)

	v, ok = maputil.GetByPath("key5.1", mp)
	assert.True(t, ok)
	assert.Equal(t, "2", v)

	v, ok = maputil.GetByPath("key5.2", mp)
	assert.True(t, ok)
	assert.Equal(t, true, v)

	// Out of bound value
	v, ok = maputil.GetByPath("key2.2", mp)
	assert.False(t, ok)
	assert.Nil(t, v)

        //...
inhere wrote this answer on 2021-07-23

:) Welcome to submit PR improvements GetByPath

More Details About Repo
Owner Name gookit
Repo Name goutil
Full Name gookit/goutil
Language Go
Created Date 2018-07-03
Updated Date 2023-03-22
Star Count 1263
Watcher Count 29
Fork Count 142
Issue Count 3

YOU MAY BE INTERESTED

Issue Title Created Date Comment Count Updated Date
Automatically detect time series dataset 2 2022-11-28 2023-02-22
Model methods build with `add_processor` and `call_orders` doesn't error out if you provide non-existing args 0 2023-01-18 2023-03-07
Add pictoral symbols present in Minecraft 1.18.1 0 2022-12-27 2023-02-05
Make ligatures "monospaced" and use complex character substitution 0 2022-12-28 2023-02-05
Document which (inner) blocks are unlocked/removable and why 1 2022-05-22 2023-02-20
How to get proper depth from regular images 3 2021-06-24 2023-01-16
Wrong country report for Oracle cloud and Hurricane electric network 9 2021-02-11 2022-12-14
Junior Developer - Winton Careers 0 2021-06-12 2023-02-04
Missing MSVCP70.dll and MSVCR70.dll 7 2022-07-07 2023-02-26
Experimental models corrupted? 1 2021-09-14 2023-02-12
Getting the `index` of `renderListItem` 0 2022-08-28 2023-03-02
Outdated Fabric Loader 5 2022-05-05 2023-02-12
请问如何取消字体倾斜,SVG 目前是剧中显示如何靠左? 0 2022-01-06 2023-02-07
pack works without jei, but crashes when jei is added 2 2021-12-13 2023-02-05
Direct link for VRCSDK in Release note 3 2021-07-16 2023-03-07
🐛 DatePicker & TimePicker freeze 0 2022-05-22 2023-03-11
请问如何触发获取有道云笔记cookie? 1 2020-11-19 2023-01-29
buildScripts/addConfig: addHook() => method position 0 2023-02-04 2023-02-12
Leveraging Overrides for Resilient Customizations and Effective Bugfixes in JavaScript Frameworks 0 2023-02-03 2023-02-12
Improper function overload usage causes compiler error 0 2022-11-15 2023-01-31
Broken link in Slither recommendation due to typo in Wiki 0 2021-11-02 2023-02-27
Rel attribute is stripped from a tags 1 2022-01-19 2023-03-16
Stats app keeps crashing 5 2021-09-16 2023-03-09
Plan for dockerhub's new policy? 2 2023-03-16 2023-03-11
二级标题/三级标题上下间距似乎和Word版本不同? 12 2021-03-22 2022-05-19
ws.js doesn't connect ws-send attributes in new elements 1 2022-03-14 2023-02-13
V3 tree shaking and gl-matrix 0 2022-11-08 2023-02-26
Some CRAN checks are failing 2 2022-02-28 2023-02-26
Cannot use import map for imported libraries 0 2022-03-26 2023-03-13
Purpose key for precise location request as a parameter? 0 2021-07-01 2023-03-08
istio-1.13.5,1.14.1 and earlier verify-install failing with ✘ ValidatingWebhookConfiguration: istio-validator-istio-system.istio-system: the server could not find the requested resource 8 2022-01-22 2023-02-15
Issue with "Intl.Locale.prototype.weekInfo": Incorrect Weekend output for Brunei Darussalam 5 2022-02-27 2023-02-05
ERROR: N RID allocations of type 'Foo' were leaked at exit 1 2023-02-19 2023-03-14
[Quest] Issues with The Stone Watcher (ID: 2954) 0 2022-05-09 2022-10-31
Error when parsing error status on index creation 4 2022-02-27 2023-02-26
Add bug report option to Toast 1 2017-10-26 2023-02-24
Interface goes down FRR holds back on the static kernel routes 0 2022-10-25 2023-02-08
Android Basics issue: 0 2022-06-01 2023-02-03
L5.4 supported yet? 3 2017-02-09 2021-11-27
Implement Design patterns 2 2021-03-07 2023-03-05
Request : bwa 0 2021-11-30 2022-01-23
StackoverflowError 5 2021-12-14 2022-01-15
Unable to use docker context connected with SSH and GSSAPIAuthentication=yes 2 2021-08-12 2023-03-11
Lesson1 Deep Learning v1 0 2018-01-15 2023-02-22
Leftover Travis CI references 4 2022-08-25 2023-02-11
[FEATURE] Add a button in "Index Management" section to see the mappings/template of the index currently selected in shown list 4 2022-01-20 2023-02-23
Port forwarding Flask app not working on vscode-server 3 2022-11-03 2023-02-26
Environment redesign 16 2022-03-02 2023-02-22
time block - drop parsing format in the inner loop, maybe add datetime Value with formatter 0 2023-02-01 2023-02-28
dotnet publish options via gcloud functions deploy 0 2021-01-22 2023-02-05