MCPcopy
hub / github.com/purpleidea/mgmt / FullModuleName

Function FullModuleName

lang/embedded/embedded.go:116–135  ·  view source on GitHub ↗

FullModuleName is a helper function that returns the embedded module name. This is the parent directory that an embedded code base should use as prefix.

(moduleName string)

Source from the content-addressed store, hash-verified

114// FullModuleName is a helper function that returns the embedded module name.
115// This is the parent directory that an embedded code base should use as prefix.
116func FullModuleName(moduleName string) string {
117 pc, _, _, ok := runtime.Caller(1)
118 if !ok {
119 panic("caller info not found")
120 }
121 s := runtime.FuncForPC(pc).Name()
122 chunks := strings.Split(s, "/")
123 if len(chunks) < 2 {
124 // programming error
125 panic("split pattern not found")
126 }
127 name := chunks[len(chunks)-2]
128 if name == "" {
129 panic("name not found")
130 }
131 if moduleName == "" { // in case we only want to know the module name
132 return name
133 }
134 return name + "/" + moduleName // do the concat for the user!
135}

Callers 1

initFunction · 0.92

Calls 1

NameMethod · 0.65

Tested by

no test coverage detected