[go-nuts] Re: Is there a way to use the pakckages under vendor folder and from module cache?

2019-09-10 Thread T L
Thanks for the suggestion.

I think the replace method works, but it is some tedious.
I need to add a "go.mod" file for each of the subfolders under "oldvendor",
and add a line in the "go.mod" of the main module.

But it looks this is the only way which works currently.
It would be great if there is a simpler way to support both
always-on vendor and cached vendor at the same time.

On Tuesday, September 10, 2019 at 12:30:56 PM UTC-4, t hepudds wrote:
>
> Hello T L,
>
> I think I might not fully understand the exact scenario, but one thing 
> some people have done when they have something in their vendor directory 
> that they can't otherwise find anywhere else (e.g., perhaps because it is 
> modified, or maybe the only copy of a now-missing dependency is in your 
> vendor directory) is to rename the vendor directory to something else 
> ("oldvendor", or whatever name makes sense), and then set 'replace' 
> directives in the main project's go.mod file to point into the "oldvendor" 
> directory for whatever pieces from there are needed.
>
> For example, something like:
>
>require github.com/some/dependency v0.0.0
>
>replace github.com/some/dependency => ./oldvendor/
> github.com/some/dependency
>
> I think that would allow you to pick and choose what you want from your 
> old vendor directory.
>
> In terms of your other question, I think -mod=vendor is currently all or 
> nothing. There is a proposal to perhaps one day support partial vendoring, 
> but that is not in the current software.
>
> Regards,
> thepudds
>
> On Tuesday, September 10, 2019 at 8:59:28 AM UTC-4, T L wrote:
>>
>> I maintain an private old Go project, which depends many many old 
>> packages.
>> Before the module mode, I put all these dependency packages under the 
>> vendor folder.
>> In the developing process, from time to time, I modified some of 
>> dependency packages.
>>
>> Meanwhile, I plan to migrate the project to modules mode and need to 
>> import some new module packages.
>> I found I encountered an embarrassing situation.
>> If I delete the vendor folder and run "go mod vendor" in modules mode to 
>> rebuild the vendor,
>> the command will fail. One reason is some dependency packages disappeared.
>> The other reason is many packages are updated and broke capabilities.
>> And I don't want the new download to overwrite my local modifications for 
>> some dependency packages.
>>
>> So, is there a way to let me continue use the these old dependency 
>> packages and use some new modules based packages?
>>
>>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/39f0b51b-3b0b-434e-a784-254b0f6bca47%40googlegroups.com.


Re: [go-nuts] sqlserver error "TLS Handshake failed: x509: certificate signed by unknown authority"

2019-09-10 Thread Peggy Scott
Yes!! RUN apt-get update && apt-get install ca-certificates -y

for amd64/ubuntu:18.04

On Tuesday, September 10, 2019 at 12:28:56 PM UTC-7, Marcin Romaszewicz 
wrote:
>
> You're missing the CA Root certificates for whatever linux distribution is 
> running your application. For example, I use Alpine linux as my Docker base 
> image for my Go services, and I must install the certificates like this via 
> the Dockerfile:
>
> RUN apk update && apk add ca-certificates
>
> Find the correct way to do that in your Docker base image.
>
> -- Marcin
>
> On Tue, Sep 10, 2019 at 12:23 PM Peggy Scott  > wrote:
>
>> I am using a dockerized Golang image to connect to my Azure SQL server 
>> database. When I try to ping it, I am running into "TLS Handshake failed: 
>> x509: certificate signed by unknown authority". I am able to run my app 
>> from my box without dockerization without any issues. I am also able to 
>> able to ping my Azure Postgres server with sslmode=require without issues 
>> using the same Golang image. I am using 
>> https://github.com/denisenkom/go-mssqldb package. My connection code is:
>>
>> db, err := sql.Open("sqlserver", "server=
>> myserver.database.windows.net;user id=myuserid;"+
>>  password=mypassword;port=1433;database=mydbname;encrypt=true;
>> TrustServerCertificate=false;"+
>>  connection+timeout=30;hostNameInCertificate=*.database.windows.net;")
>>
>> if err != nil {
>> globals.Log.WithError(err).WithFields(logrus.Fields{
>> "drivername":   "sqlserver",
>> "connectionstring": "secret",
>> "error":err.Error()}).Panic("Unable to connect 
>> to db")
>>
>> What am I missing?
>>
>> -- 
>> 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 golan...@googlegroups.com .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/golang-nuts/0a0591d0-2b5a-4d21-8e95-012ba26b3900%40googlegroups.com
>>  
>> 
>> .
>>
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/fbf0462e-e7bd-45f9-8c42-9493cf80df72%40googlegroups.com.


Re: [go-nuts] Pointer to the loop variable

2019-09-10 Thread Yamil Bracho
Then turn vo into a Vertex variable, not a pointer

var vp Vertex = Vertex{}
...
if v.X == 3 {
   vp = v
  }

….

This time vp will be a copy of v,

Maybe you have to give some known values and exceptional case for your 
domain, I mean, vp  Vertex = { -1, -1} or any values your are 
positive does not exists because maybe {0,0} is good data.

HTH
PS: You can break nested loops from an inside loop using break [label]


El martes, 10 de septiembre de 2019, 14:29:50 (UTC-5), Tong Sun escribió:
>
>
>
> On Tuesday, September 10, 2019 at 3:18:47 PM UTC-4, burak serdar wrote:
>>
>> On Tue, Sep 10, 2019 at 1:13 PM Tong Sun  wrote: 
>> > 
>> > I'm experiencing a weird problem with my program and finally nail it 
>> down to what exactly went wrong, so that I can write a minimum program to 
>> duplicate it. See the following program: 
>> > 
>> > package main 
>> > 
>> > 
>> > import ( 
>> >  "fmt" 
>> > ) 
>> > 
>> > 
>> > type Vertex struct { 
>> >  X int 
>> >  Y int 
>> > } 
>> > 
>> > 
>> > func main() { 
>> >  vs := []Vertex{ 
>> >  Vertex{1, 2}, // has type Vertex 
>> >  Vertex{X: 3}, // Y:0 is implicit 
>> >  Vertex{}, // X:0 and Y:0 
>> >  } 
>> > 
>> > 
>> >  fmt.Printf("Vertex Slice %+v\n", vs) 
>> >  var vp *Vertex = nil 
>> >  for _, v := range vs { 
>> >  if v.X == 3 { 
>> >  vp =  
>> >  } 
>> >  } 
>> >  fmt.Printf("Found: %+v\n", vp) 
>> > } 
>> > 
>> > 
>> > https://play.golang.org/p/R645C5plojx 
>> > 
>> > I was expecting that the found Vertex is "v.X == 3", however the result 
>> is not. 
>>
>> Because you're keeping a pointer to the loop variable. v continues 
>> changing after you store the address of it, so you get the latest 
>> value of v. Instead, save a copy of v, or break the loop as soon as 
>> what you're looking for is found: 
>>
>
>  I can't break the loop immediately as my not-minimized real program use a 
> double loop to find the *closest *item. That's the reason I using the 
> pointer to track my finding...
>
> if v.x==3 { 
>>t:=v 
>>vp= 
>> } 
>>
>
>  OK. will do that. thx
>
> > 
>> > - what exactly is causing the problem? 
>> > - how to fix it so that I got what I was looking for? 
>> > 
>> > Again, the snip is at 
>> > https://play.golang.org/p/R645C5plojx 
>> > 
>> > 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 golan...@googlegroups.com. 
>> > To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/golang-nuts/143205c1-2c86-4404-94d2-4182a6285e21%40googlegroups.com.
>>  
>>
>>
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/839a129d-2dcf-4bac-846f-a0fc3e891ed4%40googlegroups.com.


Re: [go-nuts] Pointer to the loop variable

2019-09-10 Thread Tong Sun


On Tuesday, September 10, 2019 at 3:18:47 PM UTC-4, burak serdar wrote:
>
> On Tue, Sep 10, 2019 at 1:13 PM Tong Sun > 
> wrote: 
> > 
> > I'm experiencing a weird problem with my program and finally nail it 
> down to what exactly went wrong, so that I can write a minimum program to 
> duplicate it. See the following program: 
> > 
> > package main 
> > 
> > 
> > import ( 
> >  "fmt" 
> > ) 
> > 
> > 
> > type Vertex struct { 
> >  X int 
> >  Y int 
> > } 
> > 
> > 
> > func main() { 
> >  vs := []Vertex{ 
> >  Vertex{1, 2}, // has type Vertex 
> >  Vertex{X: 3}, // Y:0 is implicit 
> >  Vertex{}, // X:0 and Y:0 
> >  } 
> > 
> > 
> >  fmt.Printf("Vertex Slice %+v\n", vs) 
> >  var vp *Vertex = nil 
> >  for _, v := range vs { 
> >  if v.X == 3 { 
> >  vp =  
> >  } 
> >  } 
> >  fmt.Printf("Found: %+v\n", vp) 
> > } 
> > 
> > 
> > https://play.golang.org/p/R645C5plojx 
> > 
> > I was expecting that the found Vertex is "v.X == 3", however the result 
> is not. 
>
> Because you're keeping a pointer to the loop variable. v continues 
> changing after you store the address of it, so you get the latest 
> value of v. Instead, save a copy of v, or break the loop as soon as 
> what you're looking for is found: 
>

 I can't break the loop immediately as my not-minimized real program use a 
double loop to find the *closest *item. That's the reason I using the 
pointer to track my finding...

if v.x==3 { 
>t:=v 
>vp= 
> } 
>

 OK. will do that. thx

> 
> > - what exactly is causing the problem? 
> > - how to fix it so that I got what I was looking for? 
> > 
> > Again, the snip is at 
> > https://play.golang.org/p/R645C5plojx 
> > 
> > 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 golan...@googlegroups.com . 
> > To view this discussion on the web visit 
> https://groups.google.com/d/msgid/golang-nuts/143205c1-2c86-4404-94d2-4182a6285e21%40googlegroups.com.
>  
>
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/6d0d6a78-fe02-445c-bacd-29b205e05175%40googlegroups.com.


Re: [go-nuts] sqlserver error "TLS Handshake failed: x509: certificate signed by unknown authority"

2019-09-10 Thread Marcin Romaszewicz
You're missing the CA Root certificates for whatever linux distribution is
running your application. For example, I use Alpine linux as my Docker base
image for my Go services, and I must install the certificates like this via
the Dockerfile:

RUN apk update && apk add ca-certificates

Find the correct way to do that in your Docker base image.

-- Marcin

On Tue, Sep 10, 2019 at 12:23 PM Peggy Scott  wrote:

> I am using a dockerized Golang image to connect to my Azure SQL server
> database. When I try to ping it, I am running into "TLS Handshake failed:
> x509: certificate signed by unknown authority". I am able to run my app
> from my box without dockerization without any issues. I am also able to
> able to ping my Azure Postgres server with sslmode=require without issues
> using the same Golang image. I am using
> https://github.com/denisenkom/go-mssqldb package. My connection code is:
>
> db, err := sql.Open("sqlserver", 
> "server=myserver.database.windows.net;user
> id=myuserid;"+
>  password=mypassword;port=1433;database=mydbname;encrypt=true;
> TrustServerCertificate=false;"+
>  connection+timeout=30;hostNameInCertificate=*.database.windows.net;")
>
> if err != nil {
> globals.Log.WithError(err).WithFields(logrus.Fields{
> "drivername":   "sqlserver",
> "connectionstring": "secret",
> "error":err.Error()}).Panic("Unable to connect to
> db")
>
> What am I missing?
>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/golang-nuts/0a0591d0-2b5a-4d21-8e95-012ba26b3900%40googlegroups.com
> 
> .
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CA%2Bv29LsH%2BS042ckTHA8dn3pvBnUXRE6yTZpgqBx%3D97JK4P%3DdWQ%40mail.gmail.com.


[go-nuts] sqlserver error "TLS Handshake failed: x509: certificate signed by unknown authority"

2019-09-10 Thread Peggy Scott
I am using a dockerized Golang image to connect to my Azure SQL server 
database. When I try to ping it, I am running into "TLS Handshake failed: 
x509: certificate signed by unknown authority". I am able to run my app 
from my box without dockerization without any issues. I am also able to 
able to ping my Azure Postgres server with sslmode=require without issues 
using the same Golang image. I am using 
https://github.com/denisenkom/go-mssqldb package. My connection code is:

db, err := sql.Open("sqlserver", "server=myserver.database.windows.net;user 
id=myuserid;"+
 password=mypassword;port=1433;database=mydbname;encrypt=true;
TrustServerCertificate=false;"+
 connection+timeout=30;hostNameInCertificate=*.database.windows.net;")

if err != nil {
globals.Log.WithError(err).WithFields(logrus.Fields{
"drivername":   "sqlserver",
"connectionstring": "secret",
"error":err.Error()}).Panic("Unable to connect to 
db")

What am I missing?

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/0a0591d0-2b5a-4d21-8e95-012ba26b3900%40googlegroups.com.


[go-nuts] Re: Pointer to the loop variable

2019-09-10 Thread Yamil Bracho
vp is taking the address of v, so when the loop ends, v is the last element 
in the slide and therefore *vp is {0,0}
Add a break to the condition when you assign vp, say

if v.X == 3 {
 vp = 
 break
}

HTH,
Yamil

El martes, 10 de septiembre de 2019, 14:13:40 (UTC-5), Tong Sun escribió:
>
> I'm experiencing a weird problem with my program and finally nail it down 
> to what exactly went wrong, so that I can write a minimum program to 
> duplicate it. See the following program:
>
> package main
>
>
> import (
>  "fmt"
> )
>
>
> type Vertex struct {
>  X int
>  Y int
> }
>
>
> func main() {
>  vs := []Vertex{
>  Vertex{1, 2}, // has type Vertex
>  Vertex{X: 3}, // Y:0 is implicit
>  Vertex{}, // X:0 and Y:0
>  }
>
>
>  fmt.Printf("Vertex Slice %+v\n", vs)
>  var vp *Vertex = nil
>  for _, v := range vs {
>  if v.X == 3 {
>  vp = 
>  }
>  }
>  fmt.Printf("Found: %+v\n", vp)
> }
>
>
> https://play.golang.org/p/R645C5plojx
>
> I was expecting that the found Vertex is "v.X == 3", however the result is 
> not. 
>
> - what exactly is causing the problem?
> - how to fix it so that I got what I was looking for? 
>
> Again, the snip is at
> https://play.golang.org/p/R645C5plojx
>
> 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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/14f9f238-c366-4cde-8228-ecc13added04%40googlegroups.com.


[go-nuts] Pointer to the loop variable

2019-09-10 Thread Tong Sun
I'm experiencing a weird problem with my program and finally nail it down 
to what exactly went wrong, so that I can write a minimum program to 
duplicate it. See the following program:

package main


import (
 "fmt"
)


type Vertex struct {
 X int
 Y int
}


func main() {
 vs := []Vertex{
 Vertex{1, 2}, // has type Vertex
 Vertex{X: 3}, // Y:0 is implicit
 Vertex{}, // X:0 and Y:0
 }


 fmt.Printf("Vertex Slice %+v\n", vs)
 var vp *Vertex = nil
 for _, v := range vs {
 if v.X == 3 {
 vp = 
 }
 }
 fmt.Printf("Found: %+v\n", vp)
}


https://play.golang.org/p/R645C5plojx

I was expecting that the found Vertex is "v.X == 3", however the result is 
not. 

- what exactly is causing the problem?
- how to fix it so that I got what I was looking for? 

Again, the snip is at
https://play.golang.org/p/R645C5plojx

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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/143205c1-2c86-4404-94d2-4182a6285e21%40googlegroups.com.


[go-nuts] Re: Is there a way to use the pakckages under vendor folder and from module cache?

2019-09-10 Thread t hepudds
Hello T L,

I think I might not fully understand the exact scenario, but one thing some 
people have done when they have something in their vendor directory that 
they can't otherwise find anywhere else (e.g., perhaps because it is 
modified, or maybe the only copy of a now-missing dependency is in your 
vendor directory) is to rename the vendor directory to something else 
("oldvendor", or whatever name makes sense), and then set 'replace' 
directives in the main project's go.mod file to point into the "oldvendor" 
directory for whatever pieces from there are needed.

For example, something like:

   require github.com/some/dependency v0.0.0

   replace github.com/some/dependency => 
./oldvendor/github.com/some/dependency

I think that would allow you to pick and choose what you want from your old 
vendor directory.

In terms of your other question, I think -mod=vendor is currently all or 
nothing. There is a proposal to perhaps one day support partial vendoring, 
but that is not in the current software.

Regards,
thepudds

On Tuesday, September 10, 2019 at 8:59:28 AM UTC-4, T L wrote:
>
> I maintain an private old Go project, which depends many many old packages.
> Before the module mode, I put all these dependency packages under the 
> vendor folder.
> In the developing process, from time to time, I modified some of 
> dependency packages.
>
> Meanwhile, I plan to migrate the project to modules mode and need to 
> import some new module packages.
> I found I encountered an embarrassing situation.
> If I delete the vendor folder and run "go mod vendor" in modules mode to 
> rebuild the vendor,
> the command will fail. One reason is some dependency packages disappeared.
> The other reason is many packages are updated and broke capabilities.
> And I don't want the new download to overwrite my local modifications for 
> some dependency packages.
>
> So, is there a way to let me continue use the these old dependency 
> packages and use some new modules based packages?
>
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/d9491904-9e36-4230-a3f4-6c3b19e68698%40googlegroups.com.


Re: [go-nuts] Re: go mod dependency hell is real

2019-09-10 Thread t hepudds
Hello Darko,

Rather than that 'replace' you found, a better solution is probably adding 
a 'require' for a more recent release of github.com/ugorji/go.

Adding this to my go.mod worked for me in a simple test just now to resolve 
a similar error to what you reported:

  require github.com/ugorji/go v1.1.7 

Using a 'require' for a recent version is better than the 'replace' you 
found for a couple reasons, including it is more forward looking, it ages 
out more gracefully, it helps anyone importing your project (avoiding the 
problem Sam W. just commented on), etc.

Or, you likely could use a later version than v1.1.7.

The v1.1.7 release of github.com/ugorji/go was specifically targeting 
resolving the error you reported, I believe. Some more details here if 
interested:
   https://github.com/ugorji/go/issues/299

Regards,
thepudds

On Tuesday, September 10, 2019 at 9:15:46 AM UTC-4, Sam Whited wrote:
>
> Note that replace directives are not transitive, so every single user of 
> your library will need to do this. You can put it into your go.mod file 
> to get your library building and get tests passing, but your users will 
> still have to do this work as well so you'll probably want to document 
> that they now have to jump through hoops to use your library. 
>
> —Sam 
>
> On Tue, Sep 10, 2019, at 13:10, Darko Luketic wrote: 
> > The answer is apparently 
> > https://github.com/gin-gonic/gin/issues/2039#issuecomment-527997733 
> > 
> > > Add this to your go.mod file: `replace github.com/ugorji/go v1.1.4 
> > > => github.com/ugorji/go v0.0.0-20190204201341-e444a5086c43` 
> > On Tuesday, September 10, 2019 at 2:48:25 PM UTC+2, Darko 
> > Luketic wrote: 
> > > What used to work pre go 1.13 now doesn't work anymore 
>
> -- 
> Sam Whited 
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/ef689ff2-fe8b-4e8b-b01f-c96e37260f6c%40googlegroups.com.


Re: [go-nuts] Re: x/mobile: Samples for reverse binding in gomobile

2019-09-10 Thread Elias Naur
On Tue Sep 10, 2019 at 4:26 AM Jay Sharma wrote:
> --=_Part_1258_983331168.1568114760099
> Content-Type: text/plain; charset="UTF-8"
> 
> Hello @elias,
> 
> I tried the following:
> 
> 1. Created a java class : 
> 
> package reversebinding;
> 
> public class RBinding {
>  public static String getStringFromJava() {
> return "Hello from java !!";
> }
> }
> 
> 2. Generated the .class file for this file. 
> 
> 3. Generated the android binding using gomobile tool and used 
> -classpath="Path to my .class file"
> 
> 4. Binding is generated successfully. 
> 
> *But when I used that generated (.aar) file in my android app and tried to 
> trigger the api it is crashing; *
> 
> 2019-09-10 16:36:54.199 9400-9430/com.sample  E/GoLog: 2019/09/10 11:06:54 
> test.go:134: testFunction [Test]
> 2019-09-10 16:36:54.199 9400-9430/com.sample  E/GoLog: 2019/09/10 11:06:54 
> test.go:136: [Test] Now going to call a java system function 
> (System.CurrentTimeMillis()).
> 2019-09-10 16:36:54.200 9400-9434/com.sample  E/GoLog: 2019/09/10 11:06:54 
> test.go:138: [Test] Called java function return value is:  1568113614199
> 2019-09-10 16:36:54.200 9400-9434/com.sample  E/GoLog: 2019/09/10 11:06:54 
> test.go:140: [Test] Now going to call my java function.
> 2019-09-10 16:36:54.203 9400-0/com.sample  E/Go: panic: runtime error: 
> invalid memory address or nil pointer dereference
> 2019-09-10 16:36:54.203 9400-0/com.sample  E/Go: [signal SIGSEGV: 
> segmentation violation code=0x1 addr=0x0 pc=0x7568010708]
> 2019-09-10 16:36:54.203 9400-0/com.sample  E/Go: goroutine 17 [running, 
> locked to thread]:
> 2019-09-10 16:36:54.203 9400-0/com.sample  E/Go: 
> test.testFunction(0x400738)
> 2019-09-10 16:36:54.203 9400-0/com.sample  E/Go: 
> /home/test/2019/test/test.go:141 +0x190
> 2019-09-10 16:36:54.203 9400-0/com.sample  E/Go: 
> main.proxytest__testFunction(...)
> 2019-09-10 16:36:54.203 9400-0/com.sample com.sample E/Go: 
> /tmp/gomobile-work-071468276/src/gobind/go_testmain.go:199
> 2019-09-10 16:36:54.203 9400-0/com.sample  E/Go: 
> main._cgoexpwrap_5427a26f9204_proxytest__testFunction(0x8020080280200802)
> 2019-09-10 16:36:54.203 9400-0/com.sample  E/Go: _cgo_gotypes.go:606 
> +0x1c
> 2019-09-10 16:36:54.204 9400-9423/com.sample  A/libc: Fatal signal 6 
> (SIGABRT), code -6 in tid 9423 (Thread-2)
> 

The error is arguably not very helpful. Are you sure there is not another error
before the nil pointer exception? In any case, did you ensure that the .class
is included in the Android apk? An easy check is to try to call your method
from Java before trying from Go.

-- elias

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/BWWFDRSGTVCY.3RJOHGGDYAVUF%40toolbox.


Re: [go-nuts] Re: x/mobile: Samples for reverse binding in gomobile

2019-09-10 Thread Jay Sharma
Just one more information: 

I am calling from my go code like this: 
RBinding.GetStringFromJava()

On Tuesday, September 10, 2019 at 4:56:00 PM UTC+5:30, Jay Sharma wrote:
>
> Hello @elias,
>
> I tried the following:
>
> 1. Created a java class : 
>
> package reversebinding;
>
> public class RBinding {
>  public static String getStringFromJava() {
> return "Hello from java !!";
> }
> }
>
> 2. Generated the .class file for this file. 
>
> 3. Generated the android binding using gomobile tool and used 
> -classpath="Path to my .class file"
>
> 4. Binding is generated successfully. 
>
> *But when I used that generated (.aar) file in my android app and tried to 
> trigger the api it is crashing; *
>
> 2019-09-10 16:36:54.199 9400-9430/com.sample  E/GoLog: 2019/09/10 11:06:54 
> test.go:134: testFunction [Test]
> 2019-09-10 16:36:54.199 9400-9430/com.sample  E/GoLog: 2019/09/10 11:06:54 
> test.go:136: [Test] Now going to call a java system function 
> (System.CurrentTimeMillis()).
> 2019-09-10 16:36:54.200 9400-9434/com.sample  E/GoLog: 2019/09/10 11:06:54 
> test.go:138: [Test] Called java function return value is:  1568113614199
> 2019-09-10 16:36:54.200 9400-9434/com.sample  E/GoLog: 2019/09/10 11:06:54 
> test.go:140: [Test] Now going to call my java function.
> 2019-09-10 16:36:54.203 9400-0/com.sample  E/Go: panic: runtime error: 
> invalid memory address or nil pointer dereference
> 2019-09-10 16:36:54.203 9400-0/com.sample  E/Go: [signal SIGSEGV: 
> segmentation violation code=0x1 addr=0x0 pc=0x7568010708]
> 2019-09-10 16:36:54.203 9400-0/com.sample  E/Go: goroutine 17 [running, 
> locked to thread]:
> 2019-09-10 16:36:54.203 9400-0/com.sample  E/Go: 
> test.testFunction(0x400738)
> 2019-09-10 16:36:54.203 9400-0/com.sample  E/Go: 
> /home/test/2019/test/test.go:141 +0x190
> 2019-09-10 16:36:54.203 9400-0/com.sample  E/Go: 
> main.proxytest__testFunction(...)
> 2019-09-10 16:36:54.203 9400-0/com.sample com.sample E/Go: 
> /tmp/gomobile-work-071468276/src/gobind/go_testmain.go:199
> 2019-09-10 16:36:54.203 9400-0/com.sample  E/Go: 
> main._cgoexpwrap_5427a26f9204_proxytest__testFunction(0x8020080280200802)
> 2019-09-10 16:36:54.203 9400-0/com.sample  E/Go: _cgo_gotypes.go:606 
> +0x1c
> 2019-09-10 16:36:54.204 9400-9423/com.sample  A/libc: Fatal signal 6 
> (SIGABRT), code -6 in tid 9423 (Thread-2)
>
> *Can you please provide you opinion. Let me know if any other information 
> is needed. *
>
> Thanks
>
>
> On Monday, September 9, 2019 at 5:40:25 PM UTC+5:30, Elias Naur wrote:
>>
>> On Mon Sep 9, 2019 at 3:09 AM Jay Sharma wrote: 
>> > 
>> > *Next I want to try with my own classes in java.. I want to define 
>> class 
>> > and call it from go. * 
>> > *Can you please suggest, in that case how to build with gomobile ?* 
>> > 
>>
>> I think you can use the -classpath option to gomobile. 
>>
>> -- elias 
>>
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/9957ce97-b649-4733-9b46-2232f88c55a3%40googlegroups.com.


Re: [go-nuts] Re: go mod dependency hell is real

2019-09-10 Thread Sam Whited
Note that replace directives are not transitive, so every single user of
your library will need to do this. You can put it into your go.mod file
to get your library building and get tests passing, but your users will
still have to do this work as well so you'll probably want to document
that they now have to jump through hoops to use your library.

—Sam

On Tue, Sep 10, 2019, at 13:10, Darko Luketic wrote:
> The answer is apparently
> https://github.com/gin-gonic/gin/issues/2039#issuecomment-527997733
>
> > Add this to your go.mod file: `replace github.com/ugorji/go v1.1.4
> > => github.com/ugorji/go v0.0.0-20190204201341-e444a5086c43`
> On Tuesday, September 10, 2019 at 2:48:25 PM UTC+2, Darko
> Luketic wrote:
> > What used to work pre go 1.13 now doesn't work anymore

-- 
Sam Whited

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/e0919343-21e4-4703-8790-d7ff8be857ef%40www.fastmail.com.


[go-nuts] Re: Is there a way to use the pakckages under vendor folder and from module cache?

2019-09-10 Thread T L
Or can go commands support a new special folder: dependencies.
Its functionality is like the functionality of vendor folders,
but to avoid being messed up with the packages under vendors.

When running "go build -mod=vendor", the packages under the "dependencies" 
folder
have higher look-up priorities than the packages under "vendor" folder.

On Tuesday, September 10, 2019 at 9:03:52 AM UTC-4, T L wrote:
>
> I mean "to use the pakckages under vendor folder and from module cache at 
> the same time".
>
> I have one question, is it better to add a "go mod cache-locally" command 
> to save the dependency modules
> in a "module-cache" folder in the current project, so that "go build 
> -use-local-module-cache" can use
> the packages in the old "vendor" folder and the "module-cache" folder?
>
> On Tuesday, September 10, 2019 at 8:59:28 AM UTC-4, T L wrote:
>>
>> I maintain an private old Go project, which depends many many old 
>> packages.
>> Before the module mode, I put all these dependency packages under the 
>> vendor folder.
>> In the developing process, from time to time, I modified some of 
>> dependency packages.
>>
>> Meanwhile, I plan to migrate the project to modules mode and need to 
>> import some new module packages.
>> I found I encountered an embarrassing situation.
>> If I delete the vendor folder and run "go mod vendor" in modules mode to 
>> rebuild the vendor,
>> the command will fail. One reason is some dependency packages disappeared.
>> The other reason is many packages are updated and broke capabilities.
>> And I don't want the new download to overwrite my local modifications for 
>> some dependency packages.
>>
>> So, is there a way to let me continue use the these old dependency 
>> packages and use some new modules based packages?
>>
>>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/6df7328f-6894-4501-b624-91fa2660161c%40googlegroups.com.


[go-nuts] Re: go mod dependency hell is real

2019-09-10 Thread Darko Luketic
The answer is apparently
https://github.com/gin-gonic/gin/issues/2039#issuecomment-527997733

Add this to your go.mod file:
> replace github.com/ugorji/go v1.1.4 => github.com/ugorji/go 
> v0.0.0-20190204201341-e444a5086c43


On Tuesday, September 10, 2019 at 2:48:25 PM UTC+2, Darko Luketic wrote:
>
> What used to work pre go 1.13 now doesn't work anymore
>
> go mod is one big mess no one needs and complicates everything
> I'm now getting ambiguity. How do I resolve it?
> Nothing compiles anymore
>
>  ✘ darko@wrk  ~/go/src/git.icod.de/dalu/socialthing   master ●✚  go 
> mod tidy
> go: extracting github.com/ugorji/go/codec 
> v0.0.0-20181204163529-d75b2dcb6bc8
> git.icod.de/dalu/socialthing/cmd imports
> github.com/gin-gonic/gin/binding imports
> github.com/ugorji/go/codec: ambiguous import: found 
> github.com/ugorji/go/codec in multiple modules:
> github.com/ugorji/go v1.1.4 (/home/darko/go/pkg/mod/
> github.com/ugorji/go@v1.1.4/codec)
> github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8 
> (/home/darko/go/pkg/mod/
> github.com/ugorji/go/codec@v0.0.0-20181204163529-d75b2dcb6bc8)
>
>
> What does that even mean?
> Why?
> How do I fix this?
> How do I permanently disable go mod?
> I don't want it, I don't need it.
>
> build git.icod.de/dalu/socialthing: cannot load github.com/ugorji/go/codec: 
> ambiguous import: found github.com/ugorji/go/codec in multiple modules:
> github.com/ugorji/go v1.1.4 (/home/darko/go/pkg/mod/
> github.com/ugorji/go@v1.1.4/codec)
> github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8 
> (/home/darko/go/pkg/mod/
> github.com/ugorji/go/codec@v0.0.0-20181204163529-d75b2dcb6bc8)
>
> /wrist
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/3f90b8db-502b-4eca-997e-bf9202c21c46%40googlegroups.com.


[go-nuts] Re: Is there a way to use the pakckages under vendor folder and from module cache?

2019-09-10 Thread T L
I mean "to use the pakckages under vendor folder and from module cache at 
the same time".

I have one question, is it better to add a "go mod cache-locally" command 
to save the dependency modules
in a "module-cache" folder in the current project, so that "go build 
-use-local-module-cache" can use
the packages in the old "vendor" folder and the "module-cache" folder?

On Tuesday, September 10, 2019 at 8:59:28 AM UTC-4, T L wrote:
>
> I maintain an private old Go project, which depends many many old packages.
> Before the module mode, I put all these dependency packages under the 
> vendor folder.
> In the developing process, from time to time, I modified some of 
> dependency packages.
>
> Meanwhile, I plan to migrate the project to modules mode and need to 
> import some new module packages.
> I found I encountered an embarrassing situation.
> If I delete the vendor folder and run "go mod vendor" in modules mode to 
> rebuild the vendor,
> the command will fail. One reason is some dependency packages disappeared.
> The other reason is many packages are updated and broke capabilities.
> And I don't want the new download to overwrite my local modifications for 
> some dependency packages.
>
> So, is there a way to let me continue use the these old dependency 
> packages and use some new modules based packages?
>
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/a19c1fbf-fca8-4171-b830-01a226577f36%40googlegroups.com.


[go-nuts] Is there a way to use the pakckages under vendor folder and from module cache?

2019-09-10 Thread T L
I maintain an private old Go project, which depends many many old packages.
Before the module mode, I put all these dependency packages under the 
vendor folder.
In the developing process, from time to time, I modified some of dependency 
packages.

Meanwhile, I plan to migrate the project to modules mode and need to import 
some new module packages.
I found I encountered an embarrassing situation.
If I delete the vendor folder and run "go mod vendor" in modules mode to 
rebuild the vendor,
the command will fail. One reason is some dependency packages disappeared.
The other reason is many packages are updated and broke capabilities.
And I don't want the new download to overwrite my local modifications for 
some dependency packages.

So, is there a way to let me continue use the these old dependency packages 
and use some new modules based packages?

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/97d7cc59-1334-4976-a251-71795397b947%40googlegroups.com.


[go-nuts] go mod dependency hell is real

2019-09-10 Thread Darko Luketic
What used to work pre go 1.13 now doesn't work anymore

go mod is one big mess no one needs and complicates everything
I'm now getting ambiguity. How do I resolve it?
Nothing compiles anymore

 ✘ darko@wrk  ~/go/src/git.icod.de/dalu/socialthing   master ●✚  go mod 
tidy
go: extracting github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8
git.icod.de/dalu/socialthing/cmd imports
github.com/gin-gonic/gin/binding imports
github.com/ugorji/go/codec: ambiguous import: found 
github.com/ugorji/go/codec in multiple modules:
github.com/ugorji/go v1.1.4 
(/home/darko/go/pkg/mod/github.com/ugorji/go@v1.1.4/codec)
github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8 
(/home/darko/go/pkg/mod/github.com/ugorji/go/codec@v0.0.0-20181204163529-d75b2dcb6bc8)


What does that even mean?
Why?
How do I fix this?
How do I permanently disable go mod?
I don't want it, I don't need it.

build git.icod.de/dalu/socialthing: cannot load github.com/ugorji/go/codec: 
ambiguous import: found github.com/ugorji/go/codec in multiple modules:
github.com/ugorji/go v1.1.4 
(/home/darko/go/pkg/mod/github.com/ugorji/go@v1.1.4/codec)
github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8 
(/home/darko/go/pkg/mod/github.com/ugorji/go/codec@v0.0.0-20181204163529-d75b2dcb6bc8)

/wrist

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/db1df738-78fd-4ee0-933e-69ad25cb022e%40googlegroups.com.


[go-nuts] Distributing Go bindings: Go plugin vs Go archive vs Go shared package

2019-09-10 Thread julio
Hello!

I am trying to find out the best way to distribute Go bindings to a C 
library. I would like to avoid asking my users to install their target gcc 
because of cgo. So my idea is to avoid cgo by avoiding having my user 
compiling the bindings, by therefore distributing an already compiled 
package for every target GOOS and GOARCH.

Some discussions on Go plugins I found are about this precise case but it 
is not supported on Windows so far. 
But I really don't get why isn't it possible to simply use the archive 
build mode `-buildmode archive` on the bindings, then include the resulting 
Go package archive in the repo, and simply use some go CLI option in order 
to use the correct archive for the target GOOS/GOARCH?

I couldn't find out how to pass such option to the go compiler so far, so I 
was hoping for some help.

Thanks for your help,
Julio

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/601106da-f825-47cf-b0b1-56a2e026d7e4%40googlegroups.com.


Re: [go-nuts] Re: x/mobile: Samples for reverse binding in gomobile

2019-09-10 Thread Jay Sharma
Hello @elias,

I tried the following:

1. Created a java class : 

package reversebinding;

public class RBinding {
 public static String getStringFromJava() {
return "Hello from java !!";
}
}

2. Generated the .class file for this file. 

3. Generated the android binding using gomobile tool and used 
-classpath="Path to my .class file"

4. Binding is generated successfully. 

*But when I used that generated (.aar) file in my android app and tried to 
trigger the api it is crashing; *

2019-09-10 16:36:54.199 9400-9430/com.sample  E/GoLog: 2019/09/10 11:06:54 
test.go:134: testFunction [Test]
2019-09-10 16:36:54.199 9400-9430/com.sample  E/GoLog: 2019/09/10 11:06:54 
test.go:136: [Test] Now going to call a java system function 
(System.CurrentTimeMillis()).
2019-09-10 16:36:54.200 9400-9434/com.sample  E/GoLog: 2019/09/10 11:06:54 
test.go:138: [Test] Called java function return value is:  1568113614199
2019-09-10 16:36:54.200 9400-9434/com.sample  E/GoLog: 2019/09/10 11:06:54 
test.go:140: [Test] Now going to call my java function.
2019-09-10 16:36:54.203 9400-0/com.sample  E/Go: panic: runtime error: 
invalid memory address or nil pointer dereference
2019-09-10 16:36:54.203 9400-0/com.sample  E/Go: [signal SIGSEGV: 
segmentation violation code=0x1 addr=0x0 pc=0x7568010708]
2019-09-10 16:36:54.203 9400-0/com.sample  E/Go: goroutine 17 [running, 
locked to thread]:
2019-09-10 16:36:54.203 9400-0/com.sample  E/Go: 
test.testFunction(0x400738)
2019-09-10 16:36:54.203 9400-0/com.sample  E/Go: 
/home/test/2019/test/test.go:141 +0x190
2019-09-10 16:36:54.203 9400-0/com.sample  E/Go: 
main.proxytest__testFunction(...)
2019-09-10 16:36:54.203 9400-0/com.sample com.sample E/Go: 
/tmp/gomobile-work-071468276/src/gobind/go_testmain.go:199
2019-09-10 16:36:54.203 9400-0/com.sample  E/Go: 
main._cgoexpwrap_5427a26f9204_proxytest__testFunction(0x8020080280200802)
2019-09-10 16:36:54.203 9400-0/com.sample  E/Go: _cgo_gotypes.go:606 
+0x1c
2019-09-10 16:36:54.204 9400-9423/com.sample  A/libc: Fatal signal 6 
(SIGABRT), code -6 in tid 9423 (Thread-2)

*Can you please provide you opinion. Let me know if any other information 
is needed. *

Thanks


On Monday, September 9, 2019 at 5:40:25 PM UTC+5:30, Elias Naur wrote:
>
> On Mon Sep 9, 2019 at 3:09 AM Jay Sharma wrote: 
> > 
> > *Next I want to try with my own classes in java.. I want to define class 
> > and call it from go. * 
> > *Can you please suggest, in that case how to build with gomobile ?* 
> > 
>
> I think you can use the -classpath option to gomobile. 
>
> -- elias 
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/ecc0ab8e-2f04-4f76-af41-664af8c1041a%40googlegroups.com.