[go-nuts] add guru support refer folder outside gopath

2019-08-15 Thread hui zhang
"Find All References" does not find code in other packages outside GOPATHin vscode https://github.com/microsoft/vscode-go/issues/2236 https://github.com/Microsoft/vscode-go/issues/1602 https://github.com/Microsoft/vscode-go/issues/1473 the root cause is that guru did not support that. as gur

Re: [go-nuts] Proposal: provide runtime sigprocmask api to block some signal for go runtime

2019-08-14 Thread hui zhang
thanks I found a way throungh. dynamic load so dlopen("go.so") in main function after pthread_sigmask this let go runtime start after father thread , and have the same sigmask. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from

[go-nuts] Proposal: provide runtime sigprocmask api to block some signal for go runtime

2019-08-13 Thread hui zhang
check this https://groups.google.com/forum/#!topic/golang-nuts/1YvP-5V6xSI when we code golang with c, some c code used * sigwait sigwaitinfo* function to wait signal. sometime this signal is caught by golang runtime, and this cause cash. we want the signal continue to be handled by *sigwait

Re: [go-nuts] how cgo handle user define signal ? need go pass the signal handle to c

2019-08-13 Thread hui zhang
in other words we need a *go runtime signal mask .* just google, no such api provided by go yet . I want know why ? any workaround? -- 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,

Re: [go-nuts] how cgo handle user define signal ? need go pass the signal handle to c

2019-08-13 Thread hui zhang
pid, 42, val); go will catch that signal , and but ignore it and delete it what I expect is passing the signal to *sigwaitinfo* hui zhang 于2019年8月13日周二 上午9:58写道: > I am trying to extend a old c program with go.Add websocket ability to > this c program. > first build go as a .

[go-nuts] how cgo handle user define signal ? need go pass the signal handle to c

2019-08-12 Thread hui zhang
I am trying to extend a old c program with go.Add websocket ability to this c program. first build go as a .so dynamic lib then link the so lib in c program I run the cgo ok in an example program. But when integrate with old c program, c program will send a signal 42 to itself periodly.

Re: [go-nuts] how to pass c array to golang efficiently

2019-08-07 Thread hui zhang
Got it, thanks! Jan Mercl <0xj...@gmail.com> 于2019年8月7日周三 下午4:20写道: > On Wed, Aug 7, 2019 at 3:17 AM hui zhang wrote: > > > //export Send > > func Send(confid string, len int, pcm *C.short) { > >//put c.short array to int16 slice/array efficiently , how ? &

[go-nuts] how to pass c array to golang efficiently

2019-08-06 Thread hui zhang
I build go as a so called by c program how implement this Send function to make c short array to be used in go as []int16 *efficiently * of course , I can assign it one by one , but it is not an efficient way package main import "C" import "fmt" //export Summ func Summ(x, y int) int { ret

Re: [go-nuts] Re: is there a goroutine scope global veriable ?

2019-06-19 Thread hui zhang
this implement does not solve the problem. still need pass the parameter in all functions. func (g *gls) run()orfunc run (g *gls) 在 2019年6月19日星期三 UTC+8下午4:55:09,Jan Mercl写道: > > On Wed, Jun 19, 2019 at 10:41 AM hui zhang > wrote: > > > but, very few document mention

Re: [go-nuts] Re: is there a goroutine scope global veriable ?

2019-06-19 Thread hui zhang
thank you very much. Is there a golang context way to do it? 在 2019年6月19日星期三 UTC+8下午4:55:09,Jan Mercl写道: > > On Wed, Jun 19, 2019 at 10:41 AM hui zhang > wrote: > > > but, very few document mention , how to do it as goroutine local storage > . Can anyone give an exampl

Re: [go-nuts] Re: is there a goroutine scope global veriable ?

2019-06-19 Thread hui zhang
example to solve my problem , refer the code I attached? 在 2019年6月19日星期三 UTC+8上午11:03:59,Kurtis Rader写道: > > On Tue, Jun 18, 2019 at 7:56 PM hui zhang > wrote: > >> >> is there a goroutine scope global veriable ? so I can do this ? >> > > You're askin

[go-nuts] Re: is there a goroutine scope global veriable ?

2019-06-18 Thread hui zhang
is there a goroutine scope global veriable ? like fork a variable from main ? -- 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 golang-nuts+unsubscr...@googlegroup

[go-nuts] Re: is there a goroutine scope global veriable ?

2019-06-18 Thread hui zhang
is there a goroutine scope global veriable ? so I can do this ? -- 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 golang-nuts+unsubscr...@googlegroups.com. To v

[go-nuts] is there a goroutine scope global veriable ?

2019-06-18 Thread hui zhang
I write logs into one single log file. and need to set a different tracking id for each goroutine. But I don't want to pass the tracking id argument for all functions. func main() { go Func() } func Func() { SetLogTrackId("") LogDebug("123") call1() } func call1() { LogDebug("call1

[go-nuts] how to test main function coverage with different args

2019-04-23 Thread hui zhang
how to test main function coverage with different args to enhance coverage rate how to cover the red part ? for you can set args once a time func Test_main(m *testing.T) { main2() } go test -coverprofile coverage.cov -args xxx.conf go tool cover -html=coverage.cov -o coverage.html -- Yo

[go-nuts] how to go test a daemon process

2019-04-23 Thread hui zhang
I have daemon process, I try to test its coverage func Test_main(m *testing.T) { main() } go test -coverprofile coverage.out -args xxx.conf since it is a daemon, I have to kill it to stop it kill or ctrl + c I got the coverage report coverage.out only 10B and of course , no

[go-nuts] Is there a way to force to pass some function or error check when Debugging?

2019-04-22 Thread hui zhang
I am debugging a linux server program in local mac machine. some code related to environment check , such as check mount point etc. I want to pass this check , how ? - I try it set return error var to nil. but it seems not working in devel for now. - I imagine to mock function, but n

[go-nuts] go test cover on other platforms

2019-04-11 Thread hui zhang
I am developing go on mac but my test environment is on linux. Can I build a bin like GOOS=linux GOARCH=amd64 go test -c && ./sum.test and do test on linux , and get a coverage report ? how? Need install go environment on linux ? -- You received this message because you are subscribed to the

[go-nuts] go test cover with args, coverage flag has been treat like an args.

2019-04-11 Thread hui zhang
my program take 4 args like ./myprogram 1 2 3 4 *args_len=: 5* I want to test this program coverage so go test -coverprofile coverage.out -args 1 2 3 4 myprogram_test.go func Test_main(m *testing.T) { main() } DEBUG args= [/var/folders/cp/561_gl9j1wzd8dgv_fn5mk7cgn/T/go

[go-nuts] how to build golang program with a lower kernel requirement?

2018-11-29 Thread hui zhang
I build golang programe on ubuntu 18.04, try to run it on ubuntu 16.04 , it hint "kernal too old" ldd --version ldd (Ubuntu GLIBC 2.27-3ubuntu1) 2.27 #ubuntu 18.04 ldd (Ubuntu GLIBC 2.23-3ubuntu1) 2.23 #ubuntu 16.04 glibc 2.24 above requires kernel 3.2 minimum glibc 2.23 requires kernel 2.6.32.

[go-nuts] Re: different behaviour in return: error is shadowed during return

2018-11-27 Thread hui zhang
happen in go 1.10.2 1.11.2 在 2018年11月28日星期三 UTC+8上午11:02:47,hui zhang写道: > > ./main.go:212:4: err is shadowed during return > > check code above only line 212 report err > however line 203 and 212 are almost the same case. but did not report err. > -- You received this m

[go-nuts] different behaviour in return: error is shadowed during return

2018-11-27 Thread hui zhang
./main.go:212:4: err is shadowed during return check code above only line 212 report err however line 203 and 212 are almost the same case. but did not report err. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group a

Re: [go-nuts] Is there a way or lib to read a binary into a sturct{len int32;data [len]int32}

2017-11-14 Thread hui zhang
I found what I want https://github.com/lunixbochs/struc https://github.com/go-restruct/restruct 2017-11-07 18:33 GMT+08:00 Konstantin Khomoutov : > On Tue, Oct 31, 2017 at 04:36:20PM +0800, hui zhang wrote: > > [...] > > > > Is there a way or lib to read a binary into a

[go-nuts] Is there a way or lib to read a binary into a sturct{len int32;data [len]int32}

2017-10-29 Thread hui zhang
type variastrt struct { len int32 data []int32 // data length = len [len]int32 } Is there a way or lib to read a binary into a this structure in one line code? how about more complicate struct ? type complicatestrt struct { len int32 strData []variastrt } -- You received this m

[go-nuts] go/mobile: is it possible to publish go build ios app on appstore?

2017-05-03 Thread hui zhang
Here is a document to show how to publish go build app on google play https://pt.slideshare.net/takuyaueda967/go-for-mobile-games However , there is no document on how to publish go build app on app store how to do this, is it possible ? And it is much easier to integrate ios framework than ja

Re: [go-nuts] Re: How let go and c code work Alternately in the same thread

2017-04-28 Thread hui zhang
The different framework decide c/go have to be in different loop ,,a c loop and a go loop. It is hard to change that, 2017-04-28 16:17 GMT+08:00 : > > > On Friday, April 28, 2017 at 9:18:03 AM UTC+3, hui zhang wrote: >> >> How let go and c code work Alternately in

Re: [go-nuts] Re: How let go and c code work Alternately in the same thread

2017-04-28 Thread hui zhang
t;, pthread_self()); Start(); while(1) { CWork(); } return 0; } 2017-04-28 16:17 GMT+08:00 : > > > On Friday, April 28, 2017 at 9:18:03 AM UTC+3, hui zhang wrote: >> >> How let go and c code work Alternately in the same thread with >> goro

[go-nuts] How let go and c code work Alternately in the same thread

2017-04-27 Thread hui zhang
How let go and c code work Alternately in the same thread with goroutine(corouting mechanism) Check the code below. c and go code in one thread they just do work 1 by 1. Expected Result > Do CWork > Do GoWork > Do CWork > Do GoWork > Do CWork > . //c code > void CWork() { > while(1) { >

[go-nuts] Re: void type alias can not be understood in cgo

2017-04-26 Thread hui zhang
d -v void.go -->ok command-line-arguments 在 2017年4月26日星期三 UTC+8下午4:37:38,hui zhang写道: > > this code runs well on ubuntu gcc --version > gcc (Ubuntu 6.2.0-5ubuntu12) 6.2.0 20161005 > but build fail on mac > > gcc --version > > Configured with: --prefix=/Applicati

[go-nuts] Re: void type alias can not be understood in cgo

2017-04-26 Thread hui zhang
) Target: x86_64-apple-darwin15.5.0 Thread model: posix any workaround ? 在 2017年4月26日星期三 UTC+8下午3:59:15,hui zhang写道: > > I simply the case as below , how to fix it? > > package main > > /* > #include > #include > typedef void GLvoid; > GLvoid Foo() { >pr

[go-nuts] Re: void type alias can not be understood in cgo

2017-04-26 Thread hui zhang
'void') 在 2017年4月26日星期三 UTC+8下午3:20:14,hui zhang写道: > > Check code below > go call c opengl/opengles code, typedef void GLvoid > > func GenVertexArrays(n int32, arrays *uint32) { >//C.glGenVertexArrays((C.GLsizei)(n), (*C.GLuint)(unsafe.Pointer(arrays)))

[go-nuts] void type alias can not be understood in cgo

2017-04-26 Thread hui zhang
Check code below go call c opengl/opengles code, typedef void GLvoid func GenVertexArrays(n int32, arrays *uint32) { //C.glGenVertexArrays((C.GLsizei)(n), (*C.GLuint)(unsafe.Pointer(arrays))) --> ok on darwin amd64 C.glGenVertexArraysOES((C.GLsizei)(n), (*C.GLuint)(unsafe.Pointer(arr

Re: [go-nuts] how to set different flags for different os in cgo

2017-04-19 Thread hui zhang
c If I comment each #cgo sperately for defferent build , it works fine 2017-04-19 21:31 GMT+08:00 Ian Lance Taylor : > On Tue, Apr 18, 2017 at 11:00 PM, hui zhang wrote: > > I want to set different flags for different os in cgo, how to do that in > > cgo? > > > > &g

Re: [go-nuts] what is the best way to to convert c++ std::string to go string in cgo programing?

2017-04-19 Thread hui zhang
for 1) you mean > > char *CGetPath() { > return getpath().c_str(); > } this code will work ? 2017-04-19 14:43 GMT+08:00 Konstantin Khomoutov < flatw...@users.sourceforge.net>: > On Wed, 19 Apr 2017 14:23:09 +0800 > hui zhang wrote: > > > 1) getp

Re: [go-nuts] what is the best way to to convert c++ std::string to go string in cgo programing?

2017-04-18 Thread hui zhang
atw...@users.sourceforge.net>: > On Tue, 18 Apr 2017 18:09:03 -0700 (PDT) > hui zhang wrote: > > > > > c code > > > > string getstring() {...} > > > > go > > > > string gostr = (C.getstring()) > > > Oh, and note that std::string is a fat

[go-nuts] how to set different flags for different os in cgo

2017-04-18 Thread hui zhang
I want to set different flags for different os in cgo, how to do that in cgo? //#cgo amd64 darwin CFLAGS: -Dxxx > //#cgo amd64 darwin CXXFLAGS: -Dxxx > //#cgo amd64 darwin LDFLAGS: -Lxxx > //#cgo arm darwin CFLAGS: -Dxxx > //#cgo arm darwin CXXFLAGS: -Dxxx > //#cgo arm darwin LDFLAGS: -Lxxx /

Re: [go-nuts] Re: how embedded go in existing c/c++ program.

2017-04-18 Thread hui zhang
Thank you It did work . Build go code as a static c lib ,and go code also link another c lib. 在 2017年4月19日星期三 UTC+8上午9:04:37,Ian Lance Taylor写道: > > On Tue, Apr 18, 2017 at 6:01 PM, hui zhang > wrote: > > > > C functions have to be available when the Go packa

Re: [go-nuts] what is the best way to to convert c++ std::string to go string in cgo programing?

2017-04-18 Thread hui zhang
e(p) 在 2017年4月18日星期二 UTC+8下午6:44:59,Konstantin Khomoutov写道: > > On Tue, 18 Apr 2017 02:25:07 -0700 (PDT) > hui zhang > wrote: > > > c code > > string getstring() {...} > > > > go > > > > string gostr = (C.getstring()) > > Oh, an

Re: [go-nuts] Re: how embedded go in existing c/c++ program.

2017-04-18 Thread hui zhang
, c wrapper function call c function > in lib? Please reply to the mailing list, not just to me. In general all the C functions have to be available when the Go package is built. 在 2017年4月19日星期三 UTC+8上午5:58:38,Ian Lance Taylor写道: > > On Tue, Apr 18, 2017 at 1:37 AM, hui zhang > wr

[go-nuts] what is the best way to to convert c++ std::string to go string in cgo programing?

2017-04-18 Thread hui zhang
c code string getstring() {...} go string gostr = (C.getstring()) -- 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 golang-nuts+unsubscr...@googlegroups.com

[go-nuts] Re: how embedded go in existing c/c++ program.

2017-04-18 Thread hui zhang
add a c wrapper around cfunc.h not help either. 在 2017年4月18日星期二 UTC+8下午4:36:26,hui zhang写道: > > I want to embedded go code in c/c++ program. > my approach as below, however go code can not be compiled > C main() --> go func --> c func(in static lib) > > > ** >

[go-nuts] how embedded go in existing c/c++ program.

2017-04-18 Thread hui zhang
I want to embedded go code in c/c++ program. my approach as below, however go code can not be compiled C main() --> go func --> c func(in static lib) ** #include "libgofunc.h" int main() { Gofunc(); } ** CGO_ENABLED=1 go build -buildmode=c-archive -o libgofunc.a --> error U

[go-nuts] [golang/x/mobile] Can gomobile support build ios and android c static/dynamic lib.

2017-04-12 Thread hui zhang
Can gomobile support build ios and android c static/dynamic lib. For some people do not link it to objc and java directly It link with other C/C++ lib to form a common library , and then link to objc and java. For example , in cocos2dx , user use c++ to code. But some logic they need go .

[go-nuts] Re: Generate static library written in golang

2017-04-11 Thread hui zhang
I am using go1.8 arm/ darwin not work , for both bin and archive .how to solve that GOOS=darwin GOARCH=arm GOARM=7 go build -buildmode=c-archive -o libmug.a > can't load package: package .: no buildable Go source files in > > GOOS=darwin GOARCH=arm go build -v -o hello.ios main.go > r

Re: [go-nuts] how to setup go build arm support for use go on android and ios

2017-04-11 Thread hui zhang
in/amd64 > darwin/arm > darwin/arm64 > dragonfly/amd64 > freebsd/386 > freebsd/amd64 > freebsd/arm > linux/386 > linux/amd64 > linux/arm > linux/arm64 2017-04-12 9:23 GMT+08:00 hui zhang : > I am intend to build go code as c library , and link this library in > ot

Re: [go-nuts] how to setup go build arm support for use go on android and ios

2017-04-11 Thread hui zhang
I am intend to build go code as c library , and link this library in other c code . then integrate in android and ios. But I meet errors in the first step build go code as c library for arm darwin 2017-04-12 0:14 GMT+08:00 hui zhang : > I want to support go on android and ios. > >

[go-nuts] how to setup go build arm support for use go on android and ios

2017-04-11 Thread hui zhang
I want to support go on android and ios. package main > import "fmt" > import "C" > //export GoAdder > func GoAdder(x, y int) int { > fmt.Printf("Go says: adding %v and %v\n", x, y) > return x + y > } > //export GetMugenVersion > func GetMugVersion() string { > str := "Go s

[go-nuts] Is the mem layout the same between go and c?

2017-04-11 Thread hui zhang
If I define the same 2 struct in c and go can they be passed directly with unsafe.Pointer and how to export go struct from go to c ? /* #include typedef struct { int a; int b; } Foo; void pass_struct(Foo *in) { printf("%d : %d\n", in->a, in->b); } */ import "C" import ( "fmt"

[go-nuts] x/gomobile: does this project has ui support?

2017-03-31 Thread hui zhang
As far as I know , it is a wonderful work , just copy the concept for cocos2dx, it is quite suitable to build a cross platform game engine. however it is lack of a ui | particle | animation system. Much work need to be done. UI I think is the most important for now. But there seems no ui

[go-nuts] how to debug in gomobile? & can gomobile support mac or linux sometime

2017-03-29 Thread hui zhang
As too me gomobile now are more like a game engine (for ui is gl) , like cocos2dx. but unlike cocos2dx, it only support mobile, and did not offer a way to debug in wiki. how to debug, if it could not be debug in mobile. at least let it support mac or linux so , so we are easy to debug -- Yo

[go-nuts] gomobile build ios app fail

2017-03-27 Thread hui zhang
the gomobile wiki do not mention how to solve ios signing properly , only with a link that can not open. https://github.com/golang/go/wiki/Mobile Note: target=ios requires the host machine running OS X. You need to obtain a signing identity and download provisioning profiles

[go-nuts] Re: how to use go generate to generate generic code .

2017-03-10 Thread hui zhang
And pls don't tell me interface{} is good , can solve your problem bla bla bla when interface{} meet slice []int --> []interface{} , all generic can not be done 在 2017年3月10日星期五 UTC+8下午4:29:20,hui zhang写道: > > > > I want to generate a min func > > func Mi

[go-nuts] how to use go generate to generate generic code .

2017-03-10 Thread hui zhang
I want to generate a min func func Min(a,b T) T { if a < b { return a } else { return b } } pls generate below, pls use go generate to generate int int64 int32 int16 uint64 uint32 float32 float64 Pls do not just paste documents. There is a lot on google. bu

[go-nuts] why there is pointer as there are slice already?

2017-02-27 Thread hui zhang
why there is pointer as there are slice already? Can we remove pointer ? any where there is a pointer could be replaced with slice. func ptrfunc(p *int) { *p = 1 } func slicefunc(p []int) { p[0] = 1 } and we can defined a shortcut operator like ~ p[0].foo = p~foo does that

[go-nuts] can I use go develop ios lib?

2017-02-27 Thread hui zhang
I want to use go to develop a lib for both ios and android. It seems ok for android. How about ios? I know there is a project called *gomobile*. However ,after research I am not going to depend on that. I just use it in original go. Use golang to build dynamic library .so , and embedded it into

[go-nuts] how to parse script expression with go and run the script

2017-02-14 Thread hui zhang
I am developing a game engine I wish some event could be trigger by script. and this script expression is self-defined. Like below trigger.ini trigger = "power >= 1000" trigger = "statetype == A || statetype == B " trigger = "foo() > 1" - *power* and *statetype

[go-nuts] Re: How to generate generic code with generate?

2017-01-23 Thread hui zhang
{ > if r < args[i] { > r = args[i] > } > } > return r > } > > > There are other libraries out there that can do the same thing. > > On Monday, January 23, 2017 at 1:19:25 AM UTC-5, hui zhang wrote: >> >> Since go did not support generic yet , >

[go-nuts] How to use []interface{} in generic programing

2017-01-23 Thread hui zhang
check code below, How to use []interface{} in generic programing? type IReset interface { Reset() } type Fight struct { hp,mp int } func (my *Fight) Reset () { my.hp = 0 my.mp = 0 } func reset1(x IReset){ x.Reset() } func reset(x []IReset) { for i := range x { x[i].Reset()

[go-nuts] How to generate generic code with generate?

2017-01-22 Thread hui zhang
Since go did not support generic yet , Generate give us a alternative choice . However, although I read the official document. I still don't know how to use go generate to generate code. Could anyone show us an example ? Let's take std::min in c++ us an example. min(x,y) // type could b

[go-nuts] why there are so many ways to read file

2017-01-19 Thread hui zhang
check below link http://stackoverflow.com/questions/1821811/how-to-read-write-from-to-file-using-golang It offer 3 ways. os *bufio* *ioutil* -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving ema

[go-nuts] How to seek in file use bufio.Reader?

2017-01-18 Thread hui zhang
I am using bufio.Reader and binary.Read to read binary from file, I want to seek in the file or bufio.Reader Below code does not work fi.Seek(0, os.SEEK_SET) Does not work for bufio.Reader below definition shows that r control the position , but I did not see any method to set it type

Re: [go-nuts] how to seek in file using go

2017-01-18 Thread hui zhang
so the file seek does not work in bufio.Read ? 在 2017年1月19日星期四 UTC+8下午2:59:39,hui zhang写道: > > fi.Seek(0, os.SEEK_SET )? > > > I set this in the code and I expected to print 3.13 twice , but this code > print 3.13 3.14 > why? > > package main > >

Re: [go-nuts] how to seek in file using go

2017-01-18 Thread hui zhang
Endian, &pi) if err != nil { fmt.Println("binary.Read failed:", err) } fmt.Println(pi) } 在 2017年1月19日星期四 UTC+8下午2:43:31,Ayan George写道: > > > > On 01/19/2017 01:22 AM, hui zhang wrote: > > I am using encoding/binary to read/write (struct)data

Re: [go-nuts] how to seek in file using go

2017-01-18 Thread hui zhang
thanks all, I use ide go to definition, it go to the file_unix.go in this file seek is a private method. So I am confused 在 2017年1月19日星期四 UTC+8下午2:45:16,Konstantin Khomoutov写道: > > On Wed, 18 Jan 2017 22:22:48 -0800 (PST) > hui zhang > wrote: > > [...] > &g

[go-nuts] how to seek in file using go

2017-01-18 Thread hui zhang
I am using encoding/binary to read/write (struct)data to/from file. Some times , I need to seek in the file while reading . how to do this in go. Check the code below package main import ( _ "bytes" "fmt" _ "math" "bufio" "encoding/binary" "os" ) func main() { var pi flo

[go-nuts] Re: Reading an .ini file

2017-01-16 Thread hui zhang
this package is quit buggy check its issues, I list some , and still not fix yet 在 2017年1月15日星期日 UTC+8上午1:43:55,Nathan Kerr写道: > > Using a newer package might help. > > https://github.com/go-ini/ini looks to be under active development and is > written by the author of https://github.com/Unknw

Re: [go-nuts] Disadvantage of Go

2017-01-13 Thread hui zhang
Yes , cycle import is a bad design. But as the software becomes larger , not everything is controllable. In real project , some times it is a great risk to do refactor. 在 2017年1月13日星期五 UTC+8下午5:56:48,rog写道: > > On 13 January 2017 at 07:44, hui zhang > > wrote: > > 4 Ca

[go-nuts] Re: Disadvantage of Go

2017-01-13 Thread hui zhang
ault} 在 2017年1月13日星期五 UTC+8下午5:49:46,Egon写道: > > > > On Friday, 13 January 2017 11:26:29 UTC+2, hui zhang wrote: >> >> thank u very much. I know they all have work around. and I also write >> some util my own. >> I just wish go to make it more simpler, wish th

[go-nuts] Re: Disadvantage of Go

2017-01-13 Thread hui zhang
道: > > As Shawn mentioned, most of these were decided against for varying > reasons. I'll try to give as much info as I can remember. > > On Friday, 13 January 2017 09:44:10 UTC+2, hui zhang wrote: >> >> Disadvantage of Go >> 1 No Generic For Now >> &g

[go-nuts] Disadvantage of Go

2017-01-12 Thread hui zhang
Disadvantage of Go 1 No Generic For Now That make user coding repeat code many times, even for basic type such as int float bool It is not easy , even to make a generic min function. using interface will always check type casting. and for []interface{} in generic function, u can't do cast 2 In

Re: [go-nuts] strange behavior for type switch

2017-01-11 Thread hui zhang
below with > `case int,int8,int16,int32,float32,float64:` the type of v must be the > type of x, which is interface{}. You cannot convert interface{} to > float64. > > On Wed, 2017-01-11 at 18:35 -0800, hui zhang wrote: > > This is a compile error, so I don't think this

Re: [go-nuts] strange behavior for type switch

2017-01-11 Thread hui zhang
7年1月12日星期四 UTC+8上午9:21:29,kortschak写道: > > On Wed, 2017-01-11 at 17:15 -0800, hui zhang wrote: > >switch v := x.(type) { > >case int,int8,int16,int32: > > What type is v here? It can't be any of the four types you have listed > in the case since are not assigna

[go-nuts] strange behavior for type switch

2017-01-11 Thread hui zhang
check the code below , there are 3 cases There is error in the case int, int8 ,int16 line why is that func LimRange(x, low, high interface{}) float64 { var fx, flow, fhigh float64 switch v := x.(type) { case int: //OK case int8: case int16: case int32:

[go-nuts] How can I compare the interface in a generic function

2017-01-05 Thread hui zhang
How can I compare the interface ? I want to implement a generic function. the <=>= report error in this code func InRange(a, b, c interface{}) bool { if c >= a && c <= b { return true } else { return false } } -- You received this message because you are subscribed to t