Skip to content

Commit e3c957a

Browse files
author
molty3000
committed
chore: add Makefile with common targets + update .gitignore
Targets: all, build, test, test-verbose, test-race, test-cover, vet, fmt, tidy, clean, install, examples, ci
1 parent 1ac36d3 commit e3c957a

4 files changed

Lines changed: 75 additions & 18 deletions

File tree

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@ greet
33
sys-monitor
44
fs-navigator
55
db-explorer
6+
bin/
7+
coverage.out

Makefile

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
.PHONY: all build test test-verbose vet fmt tidy clean install examples
2+
3+
# Default target
4+
all: vet test build
5+
6+
# Build everything
7+
build: examples
8+
go build ./...
9+
10+
# Build example binaries
11+
examples:
12+
go build -o bin/greet ./examples/greet/
13+
go build -o bin/sys-monitor ./examples/sys-monitor/
14+
go build -o bin/fs-navigator ./examples/fs-navigator/
15+
16+
# Run tests (quiet)
17+
test:
18+
go test ./gomcp/ -count=1
19+
20+
# Run tests with verbose output
21+
test-verbose:
22+
go test ./gomcp/ -v -count=1
23+
24+
# Run tests with race detector
25+
test-race:
26+
go test ./gomcp/ -race -count=1
27+
28+
# Run tests with coverage
29+
test-cover:
30+
go test ./gomcp/ -coverprofile=coverage.out
31+
go tool cover -func=coverage.out
32+
33+
# Static analysis
34+
vet:
35+
go vet ./...
36+
37+
# Format code
38+
fmt:
39+
go fmt ./...
40+
41+
# Tidy module dependencies
42+
tidy:
43+
go mod tidy
44+
45+
# Clean built artifacts
46+
clean:
47+
rm -rf bin/
48+
rm -f coverage.out
49+
50+
# Install the package
51+
install:
52+
go install ./...
53+
54+
# Shortcut: full CI pipeline
55+
ci: fmt vet test build

examples/sys-monitor/main.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@ func main() {
3030
MimeType: "application/json",
3131
Handler: func(ctx context.Context) (string, error) {
3232
info := map[string]any{
33-
"cores": runtime.NumCPU(),
34-
"goroutines": runtime.NumGoroutine(),
35-
"go_version": runtime.Version(),
36-
"go_os": runtime.GOOS,
37-
"go_arch": runtime.GOARCH,
38-
"timestamp": time.Now().Format(time.RFC3339),
33+
"cores": runtime.NumCPU(),
34+
"goroutines": runtime.NumGoroutine(),
35+
"go_version": runtime.Version(),
36+
"go_os": runtime.GOOS,
37+
"go_arch": runtime.GOARCH,
38+
"timestamp": time.Now().Format(time.RFC3339),
3939
}
4040
data, _ := json.MarshalIndent(info, "", " ")
4141
return string(data), nil
@@ -53,15 +53,15 @@ func main() {
5353
runtime.ReadMemStats(&m)
5454

5555
info := map[string]any{
56-
"alloc_mb": m.Alloc / 1e6,
57-
"total_alloc_mb": m.TotalAlloc / 1e6,
58-
"sys_mb": m.Sys / 1e6,
59-
"heap_alloc_mb": m.HeapAlloc / 1e6,
60-
"heap_sys_mb": m.HeapSys / 1e6,
61-
"heap_objects": m.HeapObjects,
62-
"gc_cycles": m.NumGC,
56+
"alloc_mb": m.Alloc / 1e6,
57+
"total_alloc_mb": m.TotalAlloc / 1e6,
58+
"sys_mb": m.Sys / 1e6,
59+
"heap_alloc_mb": m.HeapAlloc / 1e6,
60+
"heap_sys_mb": m.HeapSys / 1e6,
61+
"heap_objects": m.HeapObjects,
62+
"gc_cycles": m.NumGC,
6363
"gc_pause_total_ms": m.PauseTotalNs / 1e6,
64-
"timestamp": time.Now().Format(time.RFC3339),
64+
"timestamp": time.Now().Format(time.RFC3339),
6565
}
6666
data, _ := json.MarshalIndent(info, "", " ")
6767
return string(data), nil

gomcp/types.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@ type Resource struct {
4545

4646
// Prompt defines a prompt template registered with the MCP server.
4747
type Prompt struct {
48-
Name string `json:"name"`
49-
Description string `json:"description,omitempty"`
50-
Arguments []PromptArg `json:"arguments,omitempty"`
51-
Handler PromptHandler `json:"-"`
48+
Name string `json:"name"`
49+
Description string `json:"description,omitempty"`
50+
Arguments []PromptArg `json:"arguments,omitempty"`
51+
Handler PromptHandler `json:"-"`
5252
}
5353

5454
// PromptArg describes an argument that a prompt template accepts.

0 commit comments

Comments
 (0)