1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2025-02-20 23:47:21 -05:00

38 lines
710 B
Go
Raw Normal View History

2017-12-03 01:04:57 +01:00
package main
import (
"fmt"
"os"
2018-09-30 18:39:53 +02:00
"path/filepath"
2017-12-03 01:04:57 +01:00
)
2020-10-04 12:39:11 +08:00
func main() {
pwd, err := os.Getwd()
2018-09-30 18:39:53 +02:00
if err != nil {
2020-10-04 12:39:11 +08:00
fmt.Println("can not get current working directory")
os.Exit(1)
}
pkg := filepath.Base(pwd)
if pkg == "v2ray-core" {
pkg = "core"
2017-12-03 01:04:57 +01:00
}
2021-05-20 05:28:52 +08:00
file, err := os.OpenFile("errors.generated.go", os.O_WRONLY|os.O_TRUNC|os.O_CREATE, 0o644)
2017-12-03 01:04:57 +01:00
if err != nil {
2021-03-24 15:18:07 +08:00
fmt.Printf("Failed to generate errors.generated.go: %v", err)
2020-10-04 12:39:11 +08:00
os.Exit(1)
2017-12-03 01:04:57 +01:00
}
2020-10-04 12:39:11 +08:00
defer file.Close()
2017-12-03 01:04:57 +01:00
2021-03-24 15:18:07 +08:00
fmt.Fprintf(file, `package %s
import "github.com/v2fly/v2ray-core/v5/common/errors"
2021-03-24 15:18:07 +08:00
type errPathObjHolder struct{}
func newError(values ...interface{}) *errors.Error {
return errors.New(values...).WithPathObj(errPathObjHolder{})
}
`, pkg)
2017-12-03 01:04:57 +01:00
}