在 Go 中进行 linting 时,有没有办法阻止使用包中的特定函数

Jam*_*e H 5 static-analysis go

是否有一种半简单的方法来阻止特定功能的使用,即fmt.Sprintf在使用 golangci-lint 或 go/analysis 等进行静态分析时,

假设你有一个包:

package a

import "fmt"

func doStuff() {
    hello := fmt.Sprintf("%s\n", "hello world") // blocked and will throw a linting error
    fmt.Println(hello)
}
Run Code Online (Sandbox Code Playgroud)

和包b:

package b

import "fmt"

func doMore() {
    hello := fmt.Sprintf("%s\n", "hello world") // allowed
    fmt.Println(hello)
}
Run Code Online (Sandbox Code Playgroud)

并且在包a中禁止使用fmt.Sprintf。