skip to content
Alvin Lucillo

Using deprecated warning

/ 1 min read

If you want to discourage developers from using a field, function, or type, you can just put Deprecated: in its own paragraph above the object.

service/service.go

package service

type Processor struct{}

// Deprecated: Use ValidateArgs instead
func (Processor) Validate(arg1 string, arg2 string) error { return nil }
func (Processor) ValidateArgs(args ...string) error       { return nil }

This helps static code analysis tool and code editors to check for deprecation warnings. In VSCode, for example, deprecated fuunction will look like below with this warning when you hover your mouse cursor over it: service.Processor{}.Validate is deprecated: Use ValidateArgs instead

// main.go

service.Processor{}.Validate("", "")