MCPcopy
hub / github.com/harness/harness / GetModuleNameFromModFile

Function GetModuleNameFromModFile

registry/app/pkg/gopackage/utils/utils.go:34–51  ·  view source on GitHub ↗

get the module name from mod file.

(modBytes io.Reader)

Source from the content-addressed store, hash-verified

32
33// get the module name from mod file.
34func GetModuleNameFromModFile(modBytes io.Reader) (string, error) {
35 moduleName := ""
36 scanner := bufio.NewScanner(modBytes)
37 for scanner.Scan() {
38 line := strings.TrimSpace(scanner.Text())
39 if strings.HasPrefix(line, "module ") {
40 moduleName = strings.TrimSpace(strings.TrimPrefix(line, "module "))
41 break
42 }
43 }
44 if err := scanner.Err(); err != nil {
45 return "", fmt.Errorf("error scanning mod file: %w", err)
46 }
47 if moduleName == "" {
48 return "", fmt.Errorf("module name not found in mod file")
49 }
50 return moduleName, nil
51}
52
53func getImageAndFileNameFromURL(path string) (string, string, error) {
54 parts := strings.SplitN(path, "/@v/", 2)

Callers 1

UploadPackageMethod · 0.92

Calls 4

ScanMethod · 0.95
TextMethod · 0.95
ErrMethod · 0.95
ErrorfMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…