@@ -16,15 +16,10 @@ import (
1616 "os"
1717 "path/filepath"
1818 "strings"
19- _ "unsafe" // For go:linkname.
2019
2120 "github.com/ydb-platform/ydb-go-sdk/v3/internal/xerrors"
2221)
2322
24- //go:linkname build_goodOSArchFile go/build.(*Context).goodOSArchFile
25- //nolint:revive
26- func build_goodOSArchFile (* build.Context , string , map [string ]bool ) bool
27-
2823//nolint:gocyclo
2924func main () {
3025 var (
@@ -64,8 +59,6 @@ func main() {
6459
6560 var writers []* Writer
6661 if isGoGenerate {
67- // We should respect Go suffixes like `_linux.go`.
68- name , tags , ext := splitOSArchTags (& buildCtx , gofile )
6962 openFile := func (name string ) (* os.File , func ()) {
7063 var f * os.File
7164 //nolint:gofumpt
@@ -82,7 +75,9 @@ func main() {
8275
8376 return f , func () { f .Close () }
8477 }
85- f , clean := openFile (name + "_gtrace" + tags + ext )
78+ ext := filepath .Ext (gofile )
79+ name := strings .TrimSuffix (gofile , ext )
80+ f , clean := openFile (name + "_gtrace" + ext )
8681 defer clean ()
8782 writers = append (writers , & Writer {
8883 Context : buildCtx ,
@@ -103,7 +98,7 @@ func main() {
10398 )
10499 fset := token .NewFileSet ()
105100 for _ , name := range buildPkg .GoFiles {
106- base , _ , _ := splitOSArchTags ( & buildCtx , name )
101+ base := strings . TrimSuffix ( name , filepath . Ext ( name ) )
107102 if isGenerated (base , "_gtrace" ) {
108103 continue
109104 }
@@ -313,38 +308,6 @@ func buildFunc(info *types.Info, traces map[string]*Trace, fn *ast.FuncType) (re
313308 )
314309}
315310
316- func splitOSArchTags (ctx * build.Context , name string ) (base , tags , ext string ) {
317- fileTags := make (map [string ]bool )
318- build_goodOSArchFile (ctx , name , fileTags )
319- ext = filepath .Ext (name )
320- switch len (fileTags ) {
321- case 0 : // *
322- base = strings .TrimSuffix (name , ext )
323-
324- case 1 : // *_GOOS or *_GOARCH
325- i := strings .LastIndexByte (name , '_' )
326-
327- base = name [:i ]
328- tags = strings .TrimSuffix (name [i :], ext )
329-
330- case 2 : // *_GOOS_GOARCH
331- var i int
332- i = strings .LastIndexByte (name , '_' )
333- i = strings .LastIndexByte (name [:i ], '_' )
334-
335- base = name [:i ]
336- tags = strings .TrimSuffix (name [i :], ext )
337-
338- default :
339- panic (fmt .Sprintf (
340- "gtrace: internal error: unexpected number of OS/arch tags: %d" ,
341- len (fileTags ),
342- ))
343- }
344-
345- return
346- }
347-
348311type Package struct {
349312 * types.Package
350313
0 commit comments