mirror of
https://github.com/caddyserver/xcaddy.git
synced 2024-11-03 07:50:30 +00:00
Add race detector support; update readme
This commit is contained in:
parent
1eaff742db
commit
4ce3d1db07
3 changed files with 15 additions and 6 deletions
10
README.md
10
README.md
|
@ -58,13 +58,13 @@ $ xcaddy build \
|
|||
--with github.com/caddyserver/ntlm-transport
|
||||
|
||||
$ xcaddy build v2.0.1 \
|
||||
--with github.com/caddyserver/ntlm-transport@v0.1.0
|
||||
--with github.com/caddyserver/ntlm-transport@v0.1.1
|
||||
|
||||
$ xcaddy build \
|
||||
--with github.com/caddyserver/ntlm-transport=../../my-fork
|
||||
|
||||
$ xcaddy build \
|
||||
--with github.com/caddyserver/ntlm-transport@v0.1.0=../../my-fork
|
||||
--with github.com/caddyserver/ntlm-transport@v0.1.1=../../my-fork
|
||||
```
|
||||
|
||||
### For plugin development
|
||||
|
@ -90,18 +90,18 @@ $ xcaddy run
|
|||
$ xcaddy run --config caddy.json
|
||||
```
|
||||
|
||||
|
||||
The race detector can be enabled by setting `CADDY_RACE_DETECTOR=1`.
|
||||
|
||||
|
||||
## Library usage
|
||||
|
||||
```go
|
||||
builder := xcaddy.Builder{
|
||||
CaddyVersion: "v2.0.0-rc.1",
|
||||
CaddyVersion: "v2.0.0",
|
||||
Plugins: []xcaddy.Dependency{
|
||||
{
|
||||
ModulePath: "github.com/caddyserver/ntlm-transport",
|
||||
Version: "v0.1.0",
|
||||
Version: "v0.1.1",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
|
@ -40,6 +40,7 @@ type Builder struct {
|
|||
Replacements []Replace `json:"replacements,omitempty"`
|
||||
TimeoutGet time.Duration `json:"timeout_get,omitempty"`
|
||||
TimeoutBuild time.Duration `json:"timeout_build,omitempty"`
|
||||
RaceDetector bool `json:"race_detector,omitempty"`
|
||||
}
|
||||
|
||||
// Build builds Caddy at the configured version with the
|
||||
|
@ -92,6 +93,9 @@ func (b Builder) Build(ctx context.Context, outputFile string) error {
|
|||
"-ldflags", "-w -s", // trim debug symbols
|
||||
"-trimpath",
|
||||
)
|
||||
if b.RaceDetector {
|
||||
cmd.Args = append(cmd.Args, "-race")
|
||||
}
|
||||
cmd.Env = env
|
||||
err = buildEnv.runCommand(ctx, cmd, b.TimeoutBuild)
|
||||
if err != nil {
|
||||
|
|
|
@ -28,7 +28,10 @@ import (
|
|||
"github.com/caddyserver/xcaddy"
|
||||
)
|
||||
|
||||
var caddyVersion = os.Getenv("CADDY_VERSION")
|
||||
var (
|
||||
caddyVersion = os.Getenv("CADDY_VERSION")
|
||||
raceDetector = os.Getenv("CADDY_RACE_DETECTOR") == "1"
|
||||
)
|
||||
|
||||
func main() {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
|
@ -109,6 +112,7 @@ func runBuild(ctx context.Context, args []string) error {
|
|||
CaddyVersion: caddyVersion,
|
||||
Plugins: plugins,
|
||||
Replacements: replacements,
|
||||
RaceDetector: raceDetector,
|
||||
}
|
||||
err := builder.Build(ctx, output)
|
||||
if err != nil {
|
||||
|
@ -190,6 +194,7 @@ func runDev(ctx context.Context, args []string) error {
|
|||
{ModulePath: currentModule},
|
||||
},
|
||||
Replacements: replacements,
|
||||
RaceDetector: raceDetector,
|
||||
}
|
||||
err = builder.Build(ctx, binOutput)
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in a new issue