-
Notifications
You must be signed in to change notification settings - Fork 3
/
example.go
48 lines (39 loc) · 801 Bytes
/
example.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
40
41
42
43
44
45
46
47
48
//go:generate go run github.com/csnewman/flutter-go-bridge/cmd/flutter-go-bridge generate --src example.go --go bridge/bridge.gen.go --dart ../lib/bridge.gen.dart
package example
import (
"fmt"
)
func Add(a int, b int) int {
return a + b
}
type Point struct {
X int
Y int
Name string
}
func AddPoints(a Point, b Point) Point {
return Point{
X: a.X + b.X,
Y: a.Y + b.Y,
Name: a.Name + "+" + b.Name,
}
}
func AddError(a int, b int) (int, error) {
return 0, fmt.Errorf("add res was %v", a+b)
}
type Obj struct {
Name string
other int
}
func NewObj(name string, other int) *Obj {
return &Obj{
Name: name,
other: other,
}
}
func ModifyObj(o *Obj) {
o.other *= 2
}
func FormatObj(o *Obj) string {
return fmt.Sprintf("Obj: Name=%v Other=%v", o.Name, o.other)
}