Skip to content

Commit 29ea3a2

Browse files
committed
update docs for dev UX
1 parent bce53ce commit 29ea3a2

File tree

6 files changed

+214
-10
lines changed

6 files changed

+214
-10
lines changed

.editorconfig

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# EditorConfig for go-micro
2+
# https://editorconfig.org
3+
4+
root = true
5+
6+
[*]
7+
charset = utf-8
8+
end_of_line = lf
9+
insert_final_newline = true
10+
trim_trailing_whitespace = true
11+
12+
[*.go]
13+
indent_style = tab
14+
indent_size = 4
15+
16+
[*.{yml,yaml}]
17+
indent_style = space
18+
indent_size = 2
19+
20+
[*.{json,proto}]
21+
indent_style = space
22+
indent_size = 2
23+
24+
[*.md]
25+
trim_trailing_whitespace = false
26+
indent_style = space
27+
indent_size = 2
28+
29+
[Makefile]
30+
indent_style = tab
31+

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ _cgo_export.*
3030

3131
# Output of the go coverage tool, specifically when used with LiteIDE
3232
*.out
33+
coverage.html
3334

3435
# vim temp files
3536
*~
@@ -39,3 +40,10 @@ _cgo_export.*
3940
# go work files
4041
go.work
4142
go.work.sum
43+
44+
# Build artifacts
45+
dist/
46+
bin/
47+
48+
# IDE-specific files
49+
.DS_Store

CONTRIBUTING.md

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,24 @@ Be respectful, inclusive, and collaborative. We're all here to build great softw
1919
# Install dependencies
2020
go mod download
2121

22+
# Install development tools
23+
make install-tools
24+
2225
# Run tests
23-
go test ./...
26+
make test
27+
28+
# Run tests with race detector and coverage
29+
make test-coverage
2430

25-
# Run tests with coverage
26-
go test -race -coverprofile=coverage.out ./...
31+
# Run linter
32+
make lint
2733

28-
# Run linter (install golangci-lint first)
29-
golangci-lint run
34+
# Format code
35+
make fmt
3036
```
3137

38+
See `make help` for all available commands.
39+
3240
## Making Changes
3341

3442
### Code Guidelines

Makefile

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
.PHONY: test test-race test-coverage lint fmt install-tools proto clean help
2+
3+
# Default target
4+
help:
5+
@echo "Go Micro Development Tasks"
6+
@echo ""
7+
@echo " make test - Run tests"
8+
@echo " make test-race - Run tests with race detector"
9+
@echo " make test-coverage - Run tests with coverage"
10+
@echo " make lint - Run linter"
11+
@echo " make fmt - Format code"
12+
@echo " make install-tools - Install development tools"
13+
@echo " make proto - Generate protobuf code"
14+
@echo " make clean - Clean build artifacts"
15+
16+
# Run tests
17+
test:
18+
go test -v ./...
19+
20+
# Run tests with race detector
21+
test-race:
22+
go test -v -race ./...
23+
24+
# Run tests with coverage
25+
test-coverage:
26+
go test -v -race -coverprofile=coverage.out -covermode=atomic ./...
27+
go tool cover -html=coverage.out -o coverage.html
28+
@echo "Coverage report: coverage.html"
29+
30+
# Run linter
31+
lint:
32+
golangci-lint run
33+
34+
# Format code
35+
fmt:
36+
gofmt -s -w .
37+
goimports -w .
38+
39+
# Install development tools
40+
install-tools:
41+
@echo "Installing development tools..."
42+
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
43+
go install golang.org/x/tools/cmd/goimports@latest
44+
go install github.com/kyoh86/richgo@latest
45+
go install go-micro.dev/v5/cmd/protoc-gen-micro@latest
46+
@echo "Tools installed successfully"
47+
48+
# Generate protobuf code
49+
proto:
50+
@echo "Generating protobuf code..."
51+
find . -name "*.proto" -not -path "./vendor/*" -exec protoc --proto_path=. --micro_out=. --go_out=. {} \;
52+
53+
# Clean build artifacts
54+
clean:
55+
rm -f coverage.out coverage.html
56+
find . -name "*.test" -type f -delete
57+
go clean -cache -testcache
58+

README.md

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -211,11 +211,19 @@ Docs: [`internal/website/docs`](internal/website/docs)
211211

212212
Package reference: https://pkg.go.dev/go-micro.dev/v5
213213

214-
Selected topics:
215-
- Getting Started: [`internal/website/docs/getting-started.md`](internal/website/docs/getting-started.md)
216-
- Plugins overview: [`internal/website/docs/plugins.md`](internal/website/docs/plugins.md)
217-
- Learn by Example: [`internal/website/docs/examples/index.md`](internal/website/docs/examples/index.md)
218-
- Performance Considerations: [`internal/website/docs/performance.md`](internal/website/docs/performance.md)
214+
**User Guides:**
215+
- [Getting Started](internal/website/docs/getting-started.md)
216+
- [Plugins Overview](internal/website/docs/plugins.md)
217+
- [Learn by Example](internal/website/docs/examples/index.md)
218+
- [Deployment Guide](internal/website/docs/deployment.md)
219+
220+
**Architecture & Performance:**
221+
- [Performance Considerations](internal/website/docs/performance.md)
222+
- [Reflection Usage & Philosophy](internal/website/docs/REFLECTION-EVALUATION-SUMMARY.md)
223+
224+
**Security:**
225+
- [TLS Security Migration](internal/website/docs/TLS_SECURITY_UPDATE.md)
226+
- [Security Migration Guide](internal/website/docs/SECURITY_MIGRATION.md)
219227

220228
## Adopters
221229

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
# Quick Start
2+
3+
Get up and running with go-micro in under 5 minutes.
4+
5+
## Install
6+
7+
```bash
8+
go install go-micro.dev/v5/cmd/micro@latest
9+
```
10+
11+
## Create Your First Service
12+
13+
```bash
14+
# Create a new service
15+
micro new helloworld
16+
cd helloworld
17+
18+
# Review the generated code
19+
ls -la
20+
21+
# Run locally with hot reload
22+
micro run
23+
24+
# Test it
25+
curl -X POST http://localhost:8080/api/helloworld/Helloworld.Call \
26+
-H "Content-Type: application/json" \
27+
-d '{"name": "World"}'
28+
```
29+
30+
## Next Steps
31+
32+
- **[Full Tutorial](getting-started.md)** - In-depth guide
33+
- **[Examples](examples/)** - Learn by example
34+
- **[API Reference](https://pkg.go.dev/go-micro.dev/v5)** - Complete API docs
35+
- **[Deployment](deployment.md)** - Deploy to production
36+
37+
## Common Patterns
38+
39+
### RPC Service
40+
```go
41+
package main
42+
43+
import "go-micro.dev/v5"
44+
45+
type Greeter struct{}
46+
47+
func (g *Greeter) Hello(ctx context.Context, req *Request, rsp *Response) error {
48+
rsp.Message = "Hello " + req.Name
49+
return nil
50+
}
51+
52+
func main() {
53+
service := micro.New("greeter")
54+
service.Handle(new(Greeter))
55+
service.Run()
56+
}
57+
```
58+
59+
### Pub/Sub Event Handler
60+
```go
61+
import "go-micro.dev/v5"
62+
63+
func main() {
64+
service := micro.New("subscriber")
65+
66+
// Subscribe to events
67+
micro.RegisterSubscriber("user.created", service.Server(),
68+
func(ctx context.Context, event *UserCreatedEvent) error {
69+
log.Infof("User created: %s", event.Email)
70+
return nil
71+
},
72+
)
73+
74+
service.Run()
75+
}
76+
```
77+
78+
### Publishing Events
79+
```go
80+
publisher := micro.NewEvent("user.created", client)
81+
publisher.Publish(ctx, &UserCreatedEvent{
82+
Email: "user@example.com",
83+
})
84+
```
85+
86+
## Get Help
87+
88+
- **[Discord Community](https://discord.gg/jwTYuUVAGh)** - Chat with other users
89+
- **[GitHub Issues](https://github.com/micro/go-micro/issues)** - Report bugs or request features
90+
- **[Documentation](https://go-micro.dev/docs/)** - Complete docs
91+

0 commit comments

Comments
 (0)