@@ -97,13 +97,7 @@ func (c call) Record(opts ...recordOption) string {
9797 funcName string
9898 file = c .file
9999 )
100- if i := strings .LastIndex (file , "/" ); i > - 1 {
101- file = file [i + 1 :]
102- }
103- if i := strings .LastIndex (name , "/" ); i > - 1 {
104- pkgPath , name = name [:i ], name [i + 1 :]
105- }
106- split := strings .Split (name , "." )
100+ file , pkgPath , split := findFileNameAndPkgPath (file , name , pkgPath )
107101 lambdas := make ([]string , 0 , len (split ))
108102 for i := range split {
109103 elem := split [len (split )- i - 1 ]
@@ -171,6 +165,23 @@ func (c call) Record(opts ...recordOption) string {
171165 return buffer .String ()
172166}
173167
168+ // findFileNameAndPkgPath extracts the file name and package path from a string and splits the name into its components.
169+ func findFileNameAndPkgPath (
170+ file string ,
171+ name string ,
172+ pkgPath string ,
173+ ) (string , string , []string ) {
174+ if i := strings .LastIndex (file , "/" ); i > - 1 {
175+ file = file [i + 1 :]
176+ }
177+ if i := strings .LastIndex (name , "/" ); i > - 1 {
178+ pkgPath , name = name [:i ], name [i + 1 :]
179+ }
180+ split := strings .Split (name , "." )
181+
182+ return file , pkgPath , split
183+ }
184+
174185func (c call ) FunctionID () string {
175186 return c .Record (Lambda (false ), FileName (false ))
176187}
0 commit comments