]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/cgo: use strings.TrimSuffix
authorcuiweixie <cuiweixie@gmail.com>
Wed, 28 Sep 2022 13:35:52 +0000 (21:35 +0800)
committerGopher Robot <gobot@golang.org>
Thu, 29 Sep 2022 09:05:05 +0000 (09:05 +0000)
Change-Id: I97b5592c678c350fd77069d7c40a98864733707a
Reviewed-on: https://go-review.googlesource.com/c/go/+/435946
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Cherry Mui <cherryyz@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>

src/cmd/cgo/out.go

index 8736455f4f4b413c05c981c79b5f9a3d08c8e424..971b845530efc81c743a0f6bca82dd4282f21355 100644 (file)
@@ -627,9 +627,7 @@ func (p *Package) writeDefsFunc(fgo2 io.Writer, n *Name, callsMalloc *bool) {
 // writeOutput creates stubs for a specific source file to be compiled by gc
 func (p *Package) writeOutput(f *File, srcfile string) {
        base := srcfile
-       if strings.HasSuffix(base, ".go") {
-               base = base[0 : len(base)-3]
-       }
+       base = strings.TrimSuffix(base, ".go")
        base = filepath.Base(base)
        fgo1 := creat(*objDir + base + ".cgo1.go")
        fgcc := creat(*objDir + base + ".cgo2.c")