Skip to content

Commit da2320f

Browse files
TestGovet and TestGofmt now passing.
1 parent 964212f commit da2320f

18 files changed

+148
-115
lines changed

SUPPORT_MATRIX.md

+2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ _examples/hi | no | yes
1717
_examples/iface | no | yes
1818
_examples/lot | yes | yes
1919
_examples/maps | yes | yes
20+
_examples/multireturn | no | yes
2021
_examples/named | yes | yes
2122
_examples/osfile | yes | yes
2223
_examples/pkgconflict | yes | yes
@@ -29,4 +30,5 @@ _examples/sliceptr | yes | yes
2930
_examples/slices | yes | yes
3031
_examples/structs | yes | yes
3132
_examples/unicode | no | yes
33+
_examples/variadic | no | yes
3234
_examples/vars | yes | yes

_examples/cpkg/run.go

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Use of this source code is governed by a BSD-style
33
// license that can be found in the LICENSE file.
44

5+
//go:build ignore
56
// +build ignore
67

78
package main

_examples/multireturn/multireturn.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,9 @@ func TripleWithInterfaceWithoutErrorFunc() (IntInterFace, IntStrUct, *IntStrUct)
103103

104104
//// Function returning function /////
105105
type FunctionType func(input int) int
106+
106107
func FunctionReturningFunction() FunctionType {
107-
return func(input int) int{
108-
return input
109-
}
108+
return func(input int) int {
109+
return input
110+
}
110111
}

_examples/variadic/variadic.go

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package variadic
22

33
/////////////// Non Variadic //////////////
4-
func NonVariFunc(arg1 int, arg2 []int, arg3 int) int{
4+
func NonVariFunc(arg1 int, arg2 []int, arg3 int) int {
55
total := arg1
66
for _, num := range arg2 {
77
total += num
@@ -12,7 +12,7 @@ func NonVariFunc(arg1 int, arg2 []int, arg3 int) int{
1212
}
1313

1414
/////////////// Variadic Over Int //////////////
15-
func VariFunc(vargs ...int) int{
15+
func VariFunc(vargs ...int) int {
1616
total := 0
1717
for _, num := range vargs {
1818
total += num
@@ -26,15 +26,15 @@ type IntStrUct struct {
2626
}
2727

2828
func NewIntStrUct(n int) IntStrUct {
29-
return IntStrUct {
30-
p:n,
29+
return IntStrUct{
30+
p: n,
3131
}
32-
}
32+
}
3333

34-
func VariStructFunc(vargs ...IntStrUct) int{
34+
func VariStructFunc(vargs ...IntStrUct) int {
3535
total := 0
3636
for _, inst := range vargs {
37-
total += inst.p
37+
total += inst.p
3838
}
3939
return total
4040
}
@@ -48,7 +48,7 @@ func (is *IntStrUct) Number() int {
4848
return is.p
4949
}
5050

51-
func VariInterFaceFunc(vargs ...IntInterFace) int{
51+
func VariInterFaceFunc(vargs ...IntInterFace) int {
5252
total := 0
5353
for _, inst := range vargs {
5454
total += inst.Number()

bind/bind.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ type BindCfg struct {
3838
// If set, python exceptions are not thrown.
3939
NoPyExceptions bool
4040

41-
// Path to Go module, which is to be used to translate Go errors to Python exceptions.
41+
// Path to Go module, which is to be used to translate Go errors to Python exceptions.
4242
ModPathGoErr2PyEx string
4343

4444
// If set, when a Go function returns a (value, err), python returns (value, ) tuple.

bind/gen.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,7 @@ var NoWarn = false
453453
// NoMake turns off generation of Makefiles
454454
var NoMake = false
455455

456-
// NoPyExceptions turns off generation of Python Exceptions
456+
// NoPyExceptions turns off generation of Python Exceptions
457457
var NoPyExceptions = false
458458

459459
// GenPyBind generates a .go file, build.py file to enable pybindgen to create python bindings,

bind/gen_func.go

+20-20
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ package bind
66

77
import (
88
"fmt"
9+
"go/types"
910
"log"
1011
"strconv"
11-
"go/types"
1212
"strings"
1313
)
1414

@@ -111,7 +111,7 @@ func (g *pyGen) genFuncSig(sym *symbol, fsym *Func) bool {
111111
}
112112
}
113113

114-
if i!=nargs-1 || !fsym.isVariadic {
114+
if i != nargs-1 || !fsym.isVariadic {
115115
wpArgs = append(wpArgs, anm)
116116
}
117117
}
@@ -245,13 +245,13 @@ func isIfaceHandle(gdoc string) (bool, string) {
245245
}
246246

247247
func isPointer(pyfmt string) bool {
248-
if (pyfmt == "s") {
248+
if pyfmt == "s" {
249249
return true
250250
}
251251
return false
252252
}
253253

254-
func (g *pyGen)generateReturn(buildPyTuple bool, npyres int, results []*Var, retvals *[]string) {
254+
func (g *pyGen) generateReturn(buildPyTuple bool, npyres int, results []*Var, retvals *[]string) {
255255
g.gofile.Printf("\n")
256256
valueCalls := make([]string, npyres, npyres)
257257
for i := 0; i < npyres; i++ {
@@ -263,7 +263,7 @@ func (g *pyGen)generateReturn(buildPyTuple bool, npyres int, results []*Var, ret
263263
result.Name(),
264264
))
265265
}
266-
formatStr := sret.pyfmt
266+
formatStr := sret.pyfmt
267267
if sret.pyfmt == "" {
268268
formatStr = "?"
269269
}
@@ -278,10 +278,10 @@ func (g *pyGen)generateReturn(buildPyTuple bool, npyres int, results []*Var, ret
278278
}
279279

280280
if result.sym.go2py != "" {
281-
retval = result.sym.go2py + "(" + retval + ")" + result.sym.go2pyParenEx
281+
retval = result.sym.go2py + "(" + retval + ")" + result.sym.go2pyParenEx
282282
}
283283

284-
if (buildPyTuple) {
284+
if buildPyTuple {
285285
buildValueFunc := "C.Py_BuildValue1"
286286
typeCast := "unsafe.Pointer"
287287
if !isPointer(formatStr) {
@@ -301,7 +301,7 @@ func (g *pyGen)generateReturn(buildPyTuple bool, npyres int, results []*Var, ret
301301

302302
if npyres == 0 {
303303
g.gofile.Printf("return\n")
304-
} else if (buildPyTuple) {
304+
} else if buildPyTuple {
305305
g.gofile.Printf("retTuple := C.PyTuple_New(%d);\n", npyres)
306306
for i := 0; i < npyres; i++ {
307307
g.gofile.Printf("C.PyTuple_SetItem(retTuple, %d, %s);\n", i, valueCalls[i])
@@ -389,7 +389,7 @@ if __err != nil {
389389
default:
390390
na = anm
391391
}
392-
if i == len(args) - 1 && fsym.isVariadic {
392+
if i == len(args)-1 && fsym.isVariadic {
393393
na = na + "..."
394394
}
395395
callArgs = append(callArgs, na)
@@ -471,20 +471,20 @@ if __err != nil {
471471
if isMethod {
472472
if sym.isStruct() {
473473
goFuncCall = fmt.Sprintf("gopyh.Embed(vifc, reflect.TypeOf(%s{})).(%s).%s(%s)",
474-
nonPtrName(symNm),
475-
symNm,
476-
fsym.GoName(),
477-
strings.Join(callArgs, ", "))
474+
nonPtrName(symNm),
475+
symNm,
476+
fsym.GoName(),
477+
strings.Join(callArgs, ", "))
478478
} else {
479479
goFuncCall = fmt.Sprintf("vifc.(%s).%s(%s)",
480-
symNm,
481-
fsym.GoName(),
482-
strings.Join(callArgs, ", "))
480+
symNm,
481+
fsym.GoName(),
482+
strings.Join(callArgs, ", "))
483483
}
484484
} else {
485485
goFuncCall = fmt.Sprintf("%s(%s)",
486-
fsym.GoFmt(),
487-
strings.Join(callArgs, ", "))
486+
fsym.GoFmt(),
487+
strings.Join(callArgs, ", "))
488488
}
489489

490490
if nres > 0 {
@@ -501,7 +501,7 @@ if __err != nil {
501501

502502
// ReMap handle returns from pyFuncCall.
503503
for i := 0; i < npyres; i++ {
504-
if res[i].sym.hasHandle() && !res[i].sym.isPtrOrIface(){
504+
if res[i].sym.hasHandle() && !res[i].sym.isPtrOrIface() {
505505
retvals[i] = "&" + retvals[i]
506506
}
507507
}
@@ -532,7 +532,7 @@ if __err != nil {
532532
}
533533
}
534534

535-
g.generateReturn(buildPyTuple(fsym), npyres, res, &retvals);
535+
g.generateReturn(buildPyTuple(fsym), npyres, res, &retvals)
536536
} else {
537537
g.gofile.Printf("if boolPyToGo(goRun) {\n")
538538
g.gofile.Indent()

bind/package.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -245,11 +245,11 @@ func (p *Package) getDoc(parent string, o types.Object) string {
245245
res := sig.Results()
246246
results := parseFn(res)
247247

248-
if (len(results) > 0) {
249-
lastResult := res.At(len(results)-1)
248+
if len(results) > 0 {
249+
lastResult := res.At(len(results) - 1)
250250
if isErrorType(lastResult.Type()) {
251251
if !NoPyExceptions {
252-
results = results[0:len(results)-1]
252+
results = results[0 : len(results)-1]
253253
}
254254
}
255255
}

bind/symbols.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ func isPyCompatField(f *types.Var) (*symbol, error) {
147147
func getPyReturnType(sig *types.Signature) (ret []types.Type, err error) {
148148
results := sig.Results()
149149

150-
if (results.Len() == 0) {
150+
if results.Len() == 0 {
151151
return make([]types.Type, 0, 0), nil
152152
} else {
153153
outCount := results.Len()

0 commit comments

Comments
 (0)