instructions for LLMs

This commit is contained in:
sneak committed 2026-01-11 04:05:39 -08:00
1 parent 4d746027dc
commit 0f53e8f659
2 files changed
+91 -10

No files matched your search

+11 -10
View File
@@ -114,13 +114,11 @@ import (
var (
Appname string = "CHANGEME"
Version string
Buildarch string
)
func main() {
globals.Appname = Appname
globals.Version = Version
globals.Buildarch = Buildarch
fx.New(
fx.Provide(
@@ -453,6 +451,11 @@ func New(lc fx.Lifecycle, params HandlersParams) (*Handlers, error) {
### Closure-Based Handler Pattern
For JSON route handlers, both the request and the response structures are
defined in the scope of the method that returns the HandlerFunc. They can
be called simply `Request` and `Response` or slightly more descriptive
names.
All handlers return `http.HandlerFunc` using the closure pattern. This allows initialization logic to run once when the handler is created:
```go
@@ -477,6 +480,11 @@ func (s *Handlers) HandleIndex() http.HandlerFunc {
```go
// internal/handlers/now.go
func (s *Handlers) HandleNow() http.HandlerFunc {
type request struct {
// request format
}
// Response struct defined in closure scope
type response struct {
Now time.Time `json:"now"`
@@ -816,7 +824,6 @@ func (l *Logger) Identify() {
l.log.Info("starting",
"appname", l.params.Globals.Appname,
"version", l.params.Globals.Version,
"buildarch", l.params.Globals.Buildarch,
)
}
```
@@ -938,20 +945,17 @@ import "go.uber.org/fx"
var (
Appname string
Version string
Buildarch string
)
// Struct for DI
type Globals struct {
Appname string
Version string
Buildarch string
}
func New(lc fx.Lifecycle) (*Globals, error) {
n := &Globals{
Appname: Appname,
Buildarch: Buildarch,
Version: Version,
}
return n, nil
@@ -965,13 +969,11 @@ func New(lc fx.Lifecycle) (*Globals, error) {
var (
Appname string = "CHANGEME" // Default, overridden by build
Version string // Set at build time
Buildarch string // Set at build time
)
func main() {
globals.Appname = Appname
globals.Version = Version
globals.Buildarch = Buildarch
// ...
}
```
@@ -982,10 +984,9 @@ Use ldflags to inject version information at build time:
```makefile
VERSION := $(shell git describe --tags --always)
BUILDARCH := $(shell go env GOARCH)
build:
go build -ldflags "-X main.Version=$(VERSION) -X main.Buildarch=$(BUILDARCH)" ./cmd/httpd
go build -ldflags "-X main.Version=$(VERSION)" ./cmd/httpd
```
---