1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
| package main
|
| import (
| "fmt"
| "os"
| "path/filepath"
| )
|
| func main() {
| pwd, err := os.Getwd()
| if err != nil {
| fmt.Println("can not get current working directory")
| os.Exit(1)
| }
| pkg := filepath.Base(pwd)
| if pkg == "v2ray-core" {
| pkg = "core"
| }
|
| file, err := os.OpenFile("errors.generated.go", os.O_WRONLY|os.O_TRUNC|os.O_CREATE, 0o644)
| if err != nil {
| fmt.Printf("Failed to generate errors.generated.go: %v", err)
| os.Exit(1)
| }
| defer file.Close()
|
| fmt.Fprintf(file, `package %s
|
| import "github.com/v2fly/v2ray-core/v5/common/errors"
|
| type errPathObjHolder struct{}
|
| func newError(values ...interface{}) *errors.Error {
| return errors.New(values...).WithPathObj(errPathObjHolder{})
| }
| `, pkg)
| }
|
|