Re: [go-nuts] Re: issues about struct align

2017-05-31 Thread xjdrew
Marvin, thanks. It seems I have to keep my manual padding! best regards, xjdrew On Tuesday, May 23, 2017 at 9:27:32 PM UTC+8, Marvin Renich wrote: > > * Marvin Renich > [170523 08:58]: > > Looking more closely at the MSDN docs for FwpmFilterAdd0 and > > FWPM_FILTER0, if

Re: [go-nuts] Re: issues about struct align

2017-05-22 Thread xjdrew
dding ProviderContextKey GUID // the max size field of that anonymous union Reserved *GUID reserved2 uint32 // mannul padding FilterId uint64 EffectiveWeight FWP_VALUE0 } Now I can run my code in 32bit go. But I hope my code can run 64bit go without any conditional compile. best regards, x

[go-nuts] Re: issues about struct align

2017-05-21 Thread xjdrew
it work with win32 api. best regards, xjdrew On Sunday, May 21, 2017 at 11:28:59 PM UTC+8, peterGo wrote: > > xjdrew, > > The Go Playground is (GOOS/GOARCH) nacl/amd64p32 which is a 64 bit > architecture, where the address space is limited to a 4GB (32 bit) window. > It has 8

[go-nuts] Re: can i get goroutine`s id or have some local storage of a goroutine?

2017-05-21 Thread xjdrew
Do you call B and C with any arguments? if you have call B and C with req, you can use the method: req.WithContext as below: func A(w http.ResponseWriter, req *http.Request) { ctx := Context.WithValue(req.Context(), "log", log) req := req.WithContext(ctx) B(req) C(req) } func B(req) {

Re: [go-nuts] issues about struct align

2017-05-20 Thread xjdrew
gcc -o align align.c drew@drew-PC MSYS /e/examples/c $ ./align.exe 4 16 the gcc verison is: $ gcc -v Using built-in specs. COLLECT_GCC=D:\msys64\mingw32\bin\gcc.exe COLLECT_LTO_WRAPPER=D:/msys64/mingw32/bin/../lib/gcc/i686-w64-mingw32/6.3.0/ lto-wrapper.exe Target: i686-w64-mingw32 Best regards, xjd

Re: [go-nuts] issues about struct align

2017-05-20 Thread xjdrew
ytes? Best Regards, xjdrew On Friday, May 19, 2017 at 9:07:58 PM UTC+8, ohir wrote: > > Dnia 2017-05-19, o godz. 04:28:53 > xjdrew > napisaƂ(a): > > > uint64 should aligin in 8 bytes, why it aligns in 4 bytes in > > go1.8.1.linux-386? > > uint64 member IS 8 byt

[go-nuts] issues about struct align

2017-05-19 Thread xjdrew
Hello everyone, Code as below, playground url(https://play.golang.org/p/XSx--6uF0E): package main import "fmt" import "unsafe" type A struct { a uint8 b uint64 } func main() { a := &A{} fmt.Println(unsafe.Sizeof(a)) fmt.Println(unsafe.Sizeof(*a)) } When I run the code in go playground

Re: [go-nuts] How to distinguish a interface{} from a real type value?

2017-04-12 Thread xjdrew
On 11 Apr 2017, at 11:32, xjdrew > > wrote: > > > > package main > > > > import ( > > "reflect" > > ) > > > > func main() { > > var a interface{} > > a = 5 > > b

[go-nuts] How to distinguish a interface{} from a real type value?

2017-04-11 Thread xjdrew
package main import ( "reflect" ) func main() { var a interface{} a = 5 b := 5 println(a == b) println(reflect.TypeOf(a) == reflect.TypeOf(b)) } As the above code show, a is a interface{} associated with a int value, b is int, how can I point out the difference of their type? play ground: http