gitlab.com/evatix-go/core@v1.3.55/codestack/MethodNamePackageName.go (about)

     1  package codestack
     2  
     3  import (
     4  	"strings"
     5  
     6  	"gitlab.com/evatix-go/core/constants"
     7  	"gitlab.com/evatix-go/core/coredata/stringslice"
     8  )
     9  
    10  func MethodNamePackageName(fullFuncName string) (fullMethodName, packageName, methodName string) {
    11  	if fullFuncName == "" {
    12  		return "", "", ""
    13  	}
    14  
    15  	hasComplexName := strings.HasPrefix(
    16  		fullFuncName,
    17  		gitlabDotCom) ||
    18  		strings.ContainsRune(
    19  			fullFuncName,
    20  			constants.ForwardRune)
    21  
    22  	if hasComplexName {
    23  		forwardSlashFound := strings.LastIndexByte(
    24  			fullFuncName,
    25  			constants.ForwardChar)
    26  
    27  		return MethodNamePackageName(fullFuncName[forwardSlashFound+1:])
    28  	}
    29  
    30  	splitsByDot := strings.Split(fullFuncName, constants.Dot)
    31  	packageName, methodName = stringslice.FirstLastDefault(splitsByDot)
    32  
    33  	return fullFuncName, packageName, methodName
    34  }