golang/go · error
no trace file supplied
Error message
no trace file supplied
What it means
trace.Start requires a destination file path; passing an empty string is rejected up front. This is the entry point backing the `go trace` (trace viewer) command's file handling.
Source
Thrown at src/cmd/go/internal/trace/trace.go:184
func (t *tracer) getNextFlowID() uint64 {
return t.nextFlowID.Add(1)
}
// traceKey is the context key for tracing information. It is unexported to prevent collisions with context keys defined in
// other packages.
type traceKey struct{}
type traceContext struct {
t *tracer
tid uint64
}
// Start starts a trace which writes to the given file.
func Start(ctx context.Context, file string) (context.Context, func() error, error) {
traceStarted.Store(true)
if file == "" {
return nil, nil, errors.New("no trace file supplied")
}
f, err := os.Create(file)
if err != nil {
return nil, nil, err
}
t := &tracer{file: make(chan traceFile, 1)}
sb := new(strings.Builder)
t.file <- traceFile{
f: f,
sb: sb,
enc: json.NewEncoder(sb),
}
ctx = context.WithValue(ctx, traceKey{}, traceContext{t: t})
return ctx, t.Close, nil
}
type traceFile struct {
f *os.FileView on GitHub (pinned to b6b368adc5)
Solutions
- Supply a non-empty file path to trace.Start / the trace subcommand.
- Generate a trace first (runtime/trace.Start) if you don't have one yet.
Example fix
// before ctx, stop, err := trace.Start(context.Background(), "") // after ctx, stop, err := trace.Start(context.Background(), "./trace.out")
Defensive patterns
Strategy: validation
Validate before calling
// Reject an empty trace file before calling Start.
func startTrace(file string) (context.Context, func() error, error) {
if file == "" { return nil, nil, errors.New("provide a trace file path") }
return trace.Start(context.Background(), file)
} Type guard
null
Try / catch
null
Prevention
- Always pass an explicit file argument to trace.Start.
- Validate CLI args before forwarding them to library calls.
When it happens
Trigger: Calling trace.Start(ctx, "") directly, or invoking the trace subcommand without supplying a trace file argument.
Common situations: Forgot the file argument; scripting that passes an empty path; mis-parsed CLI flags.
Related errors
AI-assisted analysis of golang/go@b6b368adc5 (2026-08-12).
Data as JSON: /api/errors/a3d7e2f7549b8cb5.
Report an issue: GitHub.