-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdir_layout.go
More file actions
58 lines (48 loc) · 864 Bytes
/
dir_layout.go
File metadata and controls
58 lines (48 loc) · 864 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package main
import (
"fmt"
"os"
"path/filepath"
)
func mustCreate(path string) {
err := os.MkdirAll(path, 0755)
if err != nil {
panic(err)
}
}
func writeMain(path string) {
mainPath := filepath.Join(path, "cmd", "server", "main.go")
content := `package main
import "fmt"
func main() {
fmt.Println("Hello from your Go backend!")
}
`
err := os.WriteFile(mainPath, []byte(content), 0644)
if err != nil {
panic(err)
}
}
func main() {
project := "myproject"
if len(os.Args) > 1 {
project = os.Args[1]
}
paths := []string{
"cmd/server",
"internal/api",
"internal/model",
"internal/store",
"pkg/config",
"static",
"templates",
"configs",
"scripts",
"docs",
}
for _, p := range paths {
mustCreate(filepath.Join(project, p))
}
writeMain(project)
fmt.Printf("✅ Project structure for '%s' created!\n", project)
}