I think golang package is a great stuff for encapsulation.It may be better
if I can use that in cgo.
* c/objective-c function can include any .h file in the GOPATH with "the
full path way" like golang import.
* c/objective-c function can call other c/objective-c function in another
golang package in cgo.
Here is the patch base on go1.7 that can achieve above two functional.
```diff
diff --git a/src/cmd/go/build.go b/src/cmd/go/build.go
index 3c0b994..0a035fc 100644
--- a/src/cmd/go/build.go
+++ b/src/cmd/go/build.go
@@ -3168,6 +3168,13 @@ func (b *builder) cgo(p *Package, cgoExe, obj
string, pcCFLAGS, pcLDFLAGS, cgofi
cgoCFLAGS = append([]string{"-fsanitize=memory"},
cgoCFLAGS...)
cgoLDFLAGS = append([]string{"-fsanitize=memory"},
cgoLDFLAGS...)
}
+ gopathEnv:=os.Getenv("GOPATH")
+ if gopathEnv!=""{
+ for _,gopath:=range filepath.SplitList(gopathEnv){
+ cgoCPPFLAGS = append(cgoCPPFLAGS,"-I",gopath)
+ cgoLDFLAGS = append(cgoLDFLAGS,"-I",gopath)
+ }
+ }
// Allows including _cgo_export.h from .[ch] files in the package.
cgoCPPFLAGS = append(cgoCPPFLAGS, "-I", obj)
@@ -3348,7 +3355,7 @@ func (b *builder) cgo(p *Package, cgoExe, obj string,
pcCFLAGS, pcLDFLAGS, cgofi
if pie { // we need to use -pie for Linux/ARM to get accurate
imported sym
cgoLDFLAGS = append(cgoLDFLAGS, "-pie")
}
- if err := b.gccld(p, dynobj, cgoLDFLAGS, linkobj); err != nil {
+ if err := b.gccld(p, dynobj,
append(cgoLDFLAGS,"-flat_namespace","-Wl,-undefined,warning"), linkobj);
err != nil {
return nil, nil, err
}
if pie { // but we don't need -pie for normal cgo programs
```
--
You received this message because you are subscribed to the Google Groups
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.