MCPcopy
hub / github.com/Shpota/goxygen / processFile

Method processFile

codegen/codegen.go:42–65  ·  view source on GitHub ↗

Checks if a file with the given path has to be generated, creates a directory structure, and a file with the given content.

(path string, content []byte)

Source from the content-addressed store, hash-verified

40// Checks if a file with the given path has to be generated, creates
41// a directory structure, and a file with the given content.
42func (g generator) processFile(path string, content []byte) {
43 if !g.needed(path) {
44 return
45 }
46 for _, tech := range g.techStack {
47 path = strings.Replace(path, tech+".", "", 1)
48 }
49 pathElements := strings.Split(path, "/")
50 separator := string(os.PathSeparator)
51 pathElements = append([]string{g.projectName}, pathElements...)
52 _ = os.MkdirAll(
53 strings.Join(pathElements[:len(pathElements)-1], separator),
54 os.ModePerm,
55 )
56 fmt.Println("creating: " + strings.Join(pathElements, separator))
57 err := ioutil.WriteFile(
58 strings.Join(pathElements, separator),
59 content,
60 0644,
61 )
62 if err != nil {
63 log.Fatal(err)
64 }
65}
66
67func (g generator) initGitRepo() error {
68 fmt.Println("setting up Git repository")

Callers 1

generateMethod · 0.95

Calls 1

neededMethod · 0.95

Tested by

no test coverage detected