46 lines
1.6 KiB
Markdown
46 lines
1.6 KiB
Markdown
# Go WebApp Template
|
|
|
|
## Structure
|
|
```
|
|
my-app/
|
|
├── cmd/
|
|
│ └── web/ # Individual target binary. Duplicate as needed
|
|
│ ├── app1.go
|
|
│ └── app1_test.go
|
|
├── internal/
|
|
│ ├── app/
|
|
│ │ ├── models # Code that interacts with the the DB
|
|
│ │ └── services # Works across multiple models to provide functionality
|
|
│ ├── components/ # TEMPL files and generated source
|
|
│ ├── contextutil/ # Insert and recall values from request context
|
|
│ ├── database/ # Wraps DB source(s)
|
|
│ ├── form/ # Structs for forms with validation info
|
|
│ ├── helpers/ # Assorted helper functions
|
|
│ ├── server/ # Server implementation
|
|
│ └── pkg1/ # Additional internal use package. Duplicate as needed
|
|
│ ├── pgk1.go
|
|
│ └── pgk1_test.go
|
|
├── tls/ # TLS certificates for web service
|
|
├── ui/
|
|
├── static/ # Static assets to be embedded into cmd/web binary
|
|
│ ├── css
|
|
│ ├── img
|
|
│ └── js
|
|
└── efs.go
|
|
```
|
|
|
|
|
|
## Use
|
|
- `git clone git.develent.net/wiharb/go-webapp-app.git [project-name]`
|
|
- `cd ./[project-name]`
|
|
- `rm -rf ./.git`
|
|
- Rename and duplicate `internal/pkg1` as needed
|
|
- `go mod init [package_name]`
|
|
- Update `./.vscode/launch.json::"program"` to cmd/web
|
|
- Reinitialize git
|
|
- `git init`
|
|
- `git add .`
|
|
- `git commit -m "init"`
|
|
- `git remote add origin http://[user]:[token]@git.develenet.net/wiharb/[repo].git`
|
|
- `git push -u origin master`
|