PARK, Kyung-Kook | 30 Mar 10:25 2015
Picon

object is [windows amd64 go1.4.2] expected [windows amd64 go1.4.2 X:precisestack] error

Hello gophers,

I'm trying to build a go program which is linked to a C module.
This is the standard procedure from SWIG 3.0 documentation but
I am getting following error message near the final step.

D:\Code\gowork\src\red>make
go tool 6c -I ../../../go/pkg/windows_amd64 -o ../imgui/imgui_gc.6 ../imgui/imgui_gc.c
go tool 6g -I . -o ../imgui/imgui.6 ../imgui/imgui.go
g++ -D_UNICODE -DUNICODE -I../imgui -I../imgui/gl3/include -c -o ../imgui/imgui.o ../imgui/imgui.cpp
g++ -D_UNICODE -DUNICODE -I../imgui -I../imgui/gl3/include -c -o ../imgui/imgui_wrap.o ../imgui/imgui_wrap.cxx
g++ -D_UNICODE -DUNICODE -I../imgui -I../imgui/gl3/include -c -o ../imgui/gl3/imgui_app_glfw_gl3.o ../imgui/gl3/imgui_app_glfw_gl3.cpp
g++ -D_UNICODE -DUNICODE -I../imgui -I../imgui/gl3/include -c -o ../imgui/gl3/imgui_impl_glfw_gl3.o ../imgui/gl3/imgui_impl_glfw_gl3.cpp
gcc -D_UNICODE -DUNICODE -I../imgui -I../imgui/gl3/include -c -o ../imgui/gl3/gl3w.o ../imgui/gl3/gl3w.c
go tool pack c imgui.a ../imgui/imgui_gc.6 ../imgui/imgui.6 ../imgui/imgui.o ../imgui/imgui_wrap.o ../imgui/gl3/imgui_app_glfw_gl3.o ../imgui/gl3/imgui_impl_glfw_gl3.o ../imgui/gl3/gl3w.o
go tool 6g -I . -o red.6 red.go
red.go:4: import ./imgui.a: object is [windows amd64 go1.4.2] expected [windows amd64 go1.4.2 X:precisestack]
make: *** [red.6] Error 1

My environment is Windows 8.1 64 bit and go root is built from
source code using TDM-GCC-64.

As you can see, go pack command successfully create a library.
But when I am trying to import it, it fails with error message that
looks like a platform discrepancy between the library and the compiler.

Any thoughts?

Kyung-Kook

--
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+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
For more options, visit https://groups.google.com/d/optout.
subahjit | 30 Mar 10:23 2015
Picon

Testing framework in GO for easier mocking of resources

Hi,
Is there a widely accepted test framework in the GO community  which provides the mock functionality?
The standard test library is really great for testing the independent code pieces, but is difficult for writing tests which have external resource dependencies(db, cache, logger, etc..).

Please suggest.

Thanks in advance,
Subhajit Datta

--
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+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
For more options, visit https://groups.google.com/d/optout.
Forud A | 30 Mar 08:24 2015
Picon

sql scanner for all structure

Hi gophers.

I have a lot of json (jsonb) columns in postgresql, and about 90% of them has a known structure. I use gorp, (and this question is not about gorp :) ) for each known json column, I have a structure in go, and for each structure I have a Scan function (http://golang.org/pkg/database/sql/#Scanner) so the scanner simply put data in the structure.
The problem is, I need to copy same code, in each structure I have (about 100 for now). the code is very simple, just cast src into []byte (or string in old json fields) and return error on any other type, and Unmarshal it on the reciver.

func (r *SomeType) Scan(src interface{}) error {
       
var d []byte
       
switch r.(type) {
               
[]byte:
                       d
= src.([]byte)
               
string:
                       d
= []byte(src.string)
               
default:
                       
return errors.New("unsupported type")
       
}

       
return json.Unmarshal(d, r)
}



The embeding is not good here, since there is no way to access real reciver in the embeded structure Scan function. also there is no way to get the real reciver with reflection (in my knowledge)

Is there anyway to handle this with one function? and not copy Scan function for each one? currently I use gen (https://github.com/clipperhouse/gen) with a custom typewriter to create this Scan function, but that just make thing fast, not optimized :)

--
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+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
For more options, visit https://groups.google.com/d/optout.
surfinarray | 29 Mar 03:05 2015
Picon

Parsing a Json array of Json objects.

Hi guys,

I am new to go. I am getting an array of json objects from a post ( I know what my json data will look like) here is what my structs look like:


type Options struct {    Details []User `json:"array"`}
type User struct {    EnityTitle        string `json:"entity_title"`    EntityOrgName     string `json:"entity_org_name"`    PossibleUserName  string `json:"possible_user_name"`    PossibleUserEmail string `json:"posibble_user_email"`    UserPositionTitle string `json:"user_position_title"`    MsgBodyId         int    `json:"msg_body_id"`
}


var b = []byte(`{"array":[{"entity_title":"University of Phoenix", "entity_org_name":"CS Club","possible_user_name":"Johnny Ive","posibble_user_email":"Johhny.Ive <at> uop.edu","user_position_title":"President","msg_body_id":4},{"entity_title":"University of Phoenix", "entity_org_name":"CS Club","possible_user_name":"Johnny Ive","posibble_user_email":"Johhny.Ive-kam3zbT8ll8@public.gmane.org","user_position_title":"President","msg_body_id":4}]}`)

    var opt Options
    err := json.Unmarshal(b, &opt)
    if err != nil {        panic(err)    }    log.Println(opt)


I am not sure where I'm supposed to iterate over the array and get the objects out of the array?

thanks in advanced.



--
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+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
For more options, visit https://groups.google.com/d/optout.
jtuley | 29 Mar 01:09 2015

How am I misusing http.Get?

I'm having trouble preventing HTTP requests from leaking goroutines. I've constructed a minimal example (below) that shows four leftover goroutines. And I'm closing resp.Body.

package main
import (
"io/ioutil"
"net/http"
"os"
"runtime"
"runtime/pprof"
"time"
)
func main() {
println(runtime.NumGoroutine())
resp, err := http.Get("http://www.google.com")
if err != nil {
panic(err)
}
_, _ = ioutil.ReadAll(resp.Body)
resp.Body.Close()
println(runtime.NumGoroutine())
time.Sleep(time.Second)
println(runtime.NumGoroutine())
resp, err = http.Get("http://www.google.com")
if err != nil {
panic(err)
}
_, _ = ioutil.ReadAll(resp.Body)
resp.Body.Close()
println(runtime.NumGoroutine())
t := http.DefaultTransport.(*http.Transport)
t.CloseIdleConnections()
time.Sleep(time.Second)
println(runtime.NumGoroutine())
goRoutineProfile := pprof.Lookup("goroutine")
goRoutineProfile.WriteTo(os.Stdout, 2)
}

I'm sure I'm doing something wrong, but I can't figure out what it is. When I run the above code (go 1.4.2 on Darwin), I see the output

4
8
8
8
6
goroutine 1 [running]:
runtime/pprof.writeGoroutineStacks(0x4b3ca0, 0xc208038008, 0x0, 0x0)
/usr/local/Cellar/go/1.4.2/libexec/src/runtime/pprof/pprof.go:511 +0x8d
runtime/pprof.writeGoroutine(0x4b3ca0, 0xc208038008, 0x2, 0x0, 0x0)
/usr/local/Cellar/go/1.4.2/libexec/src/runtime/pprof/pprof.go:500 +0x4f
runtime/pprof.(*Profile).WriteTo(0x404da0, 0x4b3ca0, 0xc208038008, 0x2, 0x0, 0x0)
/usr/local/Cellar/go/1.4.2/libexec/src/runtime/pprof/pprof.go:229 +0xd5
main.main()
/Users/pivotal/go/src/test/main.go:43 +0x2e7
goroutine 17 [syscall, locked to thread]:
runtime.goexit()
/usr/local/Cellar/go/1.4.2/libexec/src/runtime/asm_amd64.s:2232 +0x1
 
So the program starts with four goroutines, jumps to 8 after making the first request, stays there after waiting a second (I thought maybe something just needed time to die), is unchanged after making a second request, and drops to 6 after closing idle connections. But there are still two leaked goroutines, according to runtime.NumGoroutine(), but they don't seem to exist when the profiler runs.

I'm very confused, and would appreciate any pointers someone has.

Thanks!

--
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+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
For more options, visit https://groups.google.com/d/optout.
payel.jgec | 29 Mar 15:48 2015
Picon

Gobind installation problem

Hi,
I am trying to play around with the gomobile libhello/ example. It is written here https://github.com/golang/mobile/tree/master/example/libhello that if we modify the package "hi" then we need to run gobind manually. So, I tried to install gobind according to https://godoc.org/golang.org/x/mobile/cmd/gobind . What I did is:

cd ../src (src folder of $GOPATH)
Then ran the following command:

go install golang.org/x/mobile/cmd/gobind/

It didn't provide me anything - whether gobind is correctly installed or not?

Since, I am changing the "hi" package of gomobile I am doing:

gobind -lang=go golang.org/x/mobile/example/libhello/hi > $GOPATH/src/golang.org/x/mobile/example/libhello/hi/go_hi/go_hi.go

It is showing me:

-bash: gobind: command not found

Can anybody tell me what's going on? How can I run gobind successfully?

--
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+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
For more options, visit https://groups.google.com/d/optout.
Reed O'Brien | 29 Mar 19:17 2015

deadlock blues

Twice in two years I have needed to write something using filepath.Walk. Both times I came up with roughly the same solution, and problem.

Looking around I see people using a closure to run filepath.Walk in a goroutine. I plan to rework my code to to that. However, I would apprectiate it if someone could point out the firghteningly obvius issue with the following.

http://play.golang.org/p/0FXt4UYjyE

I can see that the channel gets closed and all the worker processes exit and decrement wg.WaiGroup, but wg.Wait() never stops waiting. So I know I must be missing something really obvious.

Any enlightenment would be appreciated.

Thx,
Reed

--
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+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
For more options, visit https://groups.google.com/d/optout.
Josh Kamau | 29 Mar 13:01 2015
Picon

Mail sent with golang smtp package not delivered to gmail

Hello;

I am trying to send am email from may application using smtp package. 

The mails are not delivered to gmail accounts but are delivered to yahoo and rackspace accounts. What could be the problem? 

I am using the 
 smtp.SendMail(emailConnStr, plainAuth, email.From, []string{email.To}, []byte(message))

The returned error is nil. 

I am using  Host: "secure.emailsrvr.com", Port:587 and my rackspace email account. 

Am i missing something? 

Thanks
Josh

--
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+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
For more options, visit https://groups.google.com/d/optout.
David Bariod | 29 Mar 10:33 2015

Re: os/exec LookPath like API extension



On Saturday, March 28, 2015 at 7:56:59 PM UTC+1, Ian Lance Taylor wrote:
On Sat, Mar 28, 2015 at 10:48 AM, David Bariod <davi...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:
>
> I suggest to add a new API to the os/exec package for retrieving all the
> path for a given binary name.
> Something like:
>
> func LookPaths(file string) ([]string, error)
>
> The function can return all the occurence of the binary in the PATH
> components.
> The purpose is to be able to use the standard library to lookup for paths
> while implementing binary wrappers.

This doesn't seem too hard to write, and it doesn't seem like
something many people will need.

Indeed it's quite simple to write such a code,
but regarding how many people will need this functionality, I can't tell.
 
I don't see a strong case for
putting it into the standard library rather than some place it can be
retrieved by go get.

Well the point is to improve an already existing functionality
rather than duplicating and tweaking already existing code.

David

--
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+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
For more options, visit https://groups.google.com/d/optout.
Joshua Liebow-Feeser | 29 Mar 10:00 2015

Proposal: extend &T{} syntax to other types

Hi,

I've tried searching for similar proposals, since I figured they probably existed, but couldn't find any. If there are any, just reply with a link and I'll shut up :)

My proposal is this. I like the &T{} syntax for struct initialization, and I don't see why it shouldn't be supported for all types. After all, for any arbitrary T, the following is valid:

t := new(T)
*t = <literal> // such as &T{}

Thus, the &<literal> syntax could work for any type.

First, the motivation. It's not uncommon to need to pass or assign pointer values to newly-initialized values. Currently this requires something like the syntax above, which is somewhat bulkier than the proposed &<literal> syntax.

Second, the plausibility. For many types it would work out of the box since the type is unambiguous:

&true
&"hello"
&[3]int{1, 2, 3}
&[]int{1, 2, 3}
&map[string]int{"one": 1}
&func(r rune) bool { return r == '\n' } // why? who am I to judge...

However, for cases with ambiguous types, it would be consistent with the current implementation to pick a default:

&1 // int
&1.0 // float64
&'1' // int32

And for types other than the default, a conversion would be sufficient (though a bit more unwieldy):

&uint(1)
&float32(1)

Thoughts?
Cheers,
Josh

--
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+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
For more options, visit https://groups.google.com/d/optout.
David DENG | 29 Mar 06:27 2015
Picon

Why this doesn't compile

http://play.golang.org/p/GAb09Xtl8j

m := make(map[string]int)
vls := []int{3, 1, 4, 2, 8}
for m["i"], m["v"] = range vls {
fmt.Println(m)
}

Looks like the spec doesn't forbid this kind of usage.

Thanks!

--
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+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
For more options, visit https://groups.google.com/d/optout.

Gmane