forked from v2fly/v2ray-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
39 lines (33 loc) · 876 Bytes
/
main.go
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
38
39
package main
import (
"fmt"
"log"
"os"
"path/filepath"
)
func getCurrentPkg() (string, error) {
path, err := os.Getwd()
if err != nil {
return "", err
}
return filepath.Base(path), nil
}
func main() {
pkg, err := getCurrentPkg()
if err != nil {
log.Fatal("Failed to get current package: ", err.Error())
return
}
file, err := os.OpenFile("errors.generated.go", os.O_WRONLY|os.O_TRUNC|os.O_CREATE, 0644)
if err != nil {
log.Fatalf("Failed to generate errors.generated.go: %v", err)
return
}
fmt.Fprintln(file, "package", pkg)
fmt.Fprintln(file, "")
fmt.Fprintln(file, "import \"v2ray.com/core/common/errors\"")
fmt.Fprintln(file, "")
fmt.Fprintln(file, "type errPathObjHolder struct {}")
fmt.Fprintln(file, "func newError(values ...interface{}) *errors.Error { return errors.New(values...).WithPathObj(errPathObjHolder{}) }")
file.Close()
}