Re: [go-nuts] Re: URL parsing with special characters.

2020-04-30 Thread Brian Candler
On Thursday, 30 April 2020 23:04:01 UTC+1, Ian Lance Taylor wrote:
>
> On Thu, Apr 30, 2020 at 11:09 AM Brian Candler  > wrote: 
> > 
> > In a URL, the percent sign should appear as %25  (% marks the start of a 
> hex-encoded character) 
> > https://play.golang.org/p/gMC1tdpJER4 
> > 
> > The URL as shown is invalid. 
>
> I *think* you are saying that the u.Path field should use %25 rather 
> than plain %.



No: I'm just saying the library is working correctly, by rejecting the 
invalid input that the OP gave.

If the input URL is correct to file%25ver3, then the parsed u.Path contains 
file%ver3 as expected.

-- 
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/453fe1df-34b0-4156-8d9c-5eaa62f485aa%40googlegroups.com.


Re: [go-nuts] Question about strings.EqualFold vs Python's casefold

2020-04-30 Thread Miki Tebeka
Thanks!

On Friday, May 1, 2020 at 8:21:48 AM UTC+3, Ian Lance Taylor wrote:
>
> On Thu, Apr 30, 2020 at 9:42 PM Miki Tebeka  > wrote: 
> > 
> > I'm trying to find an example where strings.EqualFold returns true but 
> comparison of strings.ToLower fails. 
> > I've found this example (in Python): 
> > 
> > s1 = "der Fluß" 
> > s2 = "der Fluss" 
> > 
> > print('lower', s1.lower() == s2.lower()) 
> > print('fold ', s1.casefold() == s2.casefold()) 
> > 
> > Which prints False for lower and True for casefold. 
> > 
> > When I try the same in Go 
> > package main 
> > 
> > import ( 
> > "fmt" 
> > "strings" 
> > ) 
> > 
> > func main() { 
> > 
> > s1 := "der Fluß" 
> > s2 := "der Fluss" 
> > 
> > fmt.Println("lower", strings.ToLower(s1) == strings.ToLower(s2)) 
> > fmt.Println("fold ", strings.EqualFold(s1, s2)) 
> > } 
> > 
> > I get false for both ToLower and EqualFold. 
> > 
> > Shouldn't Unicode folding be the same across languages? 
> > Also, does anyone have an example I can show in Go where ToLower does 
> not compare and EqualFold does? 
>
> strings.EqualFold uses Unicode case folding, not case mapping.  Case 
> folding is only one-to-one character transformations.  Converting "ss" 
> to "ß" is case mapping, and as such is not used by strings.EqualFold. 
> For that, you want the x/text/search package, as in 
>
> package main 
>
> import ( 
> "fmt" 
>
> "golang.org/x/text/language" 
> "golang.org/x/text/search" 
> ) 
>
> func main() { 
> m := search.New(language.German, search.Loose) 
> s1 := "der Fluß" 
> s2 := "der Fluss" 
> fmt.Println(m.EqualString(s1, s2)) 
> } 
>
> That should print true. 
>
> An example where strings.EqualFold does not return the same result as 
> strings.ToLower(s1) == strings.ToLower(s2) is 
>
> s1 := "σς" 
> s2 := "ΣΣ" 
>
> strings.EqualFold will return true but comparing the ToLower of the 
> strings will return false.  This is because there are two lower case 
> forms of Σ (depending on position in the word), but strings.ToLower 
> can of course only return one. 
>
> Ian 
>

-- 
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/3e9f1ac7-fb91-44ce-9f7c-68a1f746eba1%40googlegroups.com.


Re: [go-nuts] Question about strings.EqualFold vs Python's casefold

2020-04-30 Thread Ian Lance Taylor
On Thu, Apr 30, 2020 at 9:42 PM Miki Tebeka  wrote:
>
> I'm trying to find an example where strings.EqualFold returns true but 
> comparison of strings.ToLower fails.
> I've found this example (in Python):
>
> s1 = "der Fluß"
> s2 = "der Fluss"
>
> print('lower', s1.lower() == s2.lower())
> print('fold ', s1.casefold() == s2.casefold())
>
> Which prints False for lower and True for casefold.
>
> When I try the same in Go
> package main
>
> import (
> "fmt"
> "strings"
> )
>
> func main() {
>
> s1 := "der Fluß"
> s2 := "der Fluss"
>
> fmt.Println("lower", strings.ToLower(s1) == strings.ToLower(s2))
> fmt.Println("fold ", strings.EqualFold(s1, s2))
> }
>
> I get false for both ToLower and EqualFold.
>
> Shouldn't Unicode folding be the same across languages?
> Also, does anyone have an example I can show in Go where ToLower does not 
> compare and EqualFold does?

strings.EqualFold uses Unicode case folding, not case mapping.  Case
folding is only one-to-one character transformations.  Converting "ss"
to "ß" is case mapping, and as such is not used by strings.EqualFold.
For that, you want the x/text/search package, as in

package main

import (
"fmt"

"golang.org/x/text/language"
"golang.org/x/text/search"
)

func main() {
m := search.New(language.German, search.Loose)
s1 := "der Fluß"
s2 := "der Fluss"
fmt.Println(m.EqualString(s1, s2))
}

That should print true.

An example where strings.EqualFold does not return the same result as
strings.ToLower(s1) == strings.ToLower(s2) is

s1 := "σς"
s2 := "ΣΣ"

strings.EqualFold will return true but comparing the ToLower of the
strings will return false.  This is because there are two lower case
forms of Σ (depending on position in the word), but strings.ToLower
can of course only return one.

Ian

-- 
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/CAOyqgcU47SM2foJdGFH6mspRpppOUugLG15R_0ZhOGp2fbO6FA%40mail.gmail.com.


[go-nuts] Question about strings.EqualFold vs Python's casefold

2020-04-30 Thread Miki Tebeka
Hi,

I'm trying to find an example where strings.EqualFold returns true but 
comparison of strings.ToLower fails.
I've found this example 
 (in 
Python):

s1 = "der Fluß"
s2 = "der Fluss"

print('lower', s1.lower() == s2.lower())
print('fold ', s1.casefold() == s2.casefold())

Which prints False for lower and True for casefold.

When I try the same in Go
package main

import (
"fmt"
"strings"
)

func main() {

s1 := "der Fluß"
s2 := "der Fluss"

fmt.Println("lower", strings.ToLower(s1) == strings.ToLower(s2))
fmt.Println("fold ", strings.EqualFold(s1, s2))
}

I get false for both ToLower and EqualFold.

Shouldn't Unicode folding be the same across languages?
Also, does anyone have an example I can show in Go where ToLower does not 
compare and EqualFold does?

Thanks,
Miki

-- 
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/c61bcb93-aa76-4b8c-ae69-7bcbf0c7567c%40googlegroups.com.


Re: [go-nuts] getting values from memory addresses within another process...

2020-04-30 Thread Trig
Kurtis,

   Thanks... that 'Cheat Engine' is the correct one.  Basically, what I am 
doing is creating a simple service that watches for a particular process (a 
game, in this instance) and 'monitors' certain values (such as life levels, 
mana levels, etc.).  If my health in the game is low, it simply plays an 
audio file that let's me know to drink a potion, etc.  I'm not needing to 
write any values to memory (like a bot would actually do)... just be able 
to read them.

On Thursday, April 30, 2020 at 10:43:50 PM UTC-5, Kurtis Rader wrote:
>
> On Thu, Apr 30, 2020 at 8:25 PM Eric Brown > 
> wrote:
>
>> I’ll look into this solution.  Thank you for an answer that points me in 
>> a possible direction.
>>
>
> Gah! I hit the "send" button without providing any useful response in my 
> previous reply. Note that reading /proc/$pid/mem is only applicable to 
> Linux. And that solution basically requires your program, written in Go, to 
> be run as root.
>
> You need to provide more information about what you're trying to do. 
> Including any relevant constraints such as particular operating systems you 
> want to support. You also referenced "Cheat Engine" without providing a 
> link to a document that explains what you mean by that term. I'm guessing 
> (emphasis on "guessing") that you are referring to 
> https://en.wikipedia.org/wiki/Cheat_Engine
>
> --
> Kurtis Rader
> Caretaker of the exceptional canines Junior and Hank
>

-- 
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/6aa2b885-7f13-4743-b2a4-874294a835a9%40googlegroups.com.


Re: [go-nuts] getting values from memory addresses within another process...

2020-04-30 Thread Kurtis Rader
On Thu, Apr 30, 2020 at 8:25 PM Eric Brown  wrote:

> I’ll look into this solution.  Thank you for an answer that points me in a
> possible direction.
>

Gah! I hit the "send" button without providing any useful response in my
previous reply. Note that reading /proc/$pid/mem is only applicable to
Linux. And that solution basically requires your program, written in Go, to
be run as root.

You need to provide more information about what you're trying to do.
Including any relevant constraints such as particular operating systems you
want to support. You also referenced "Cheat Engine" without providing a
link to a document that explains what you mean by that term. I'm guessing
(emphasis on "guessing") that you are referring to
https://en.wikipedia.org/wiki/Cheat_Engine

--
Kurtis Rader
Caretaker of the exceptional canines Junior and Hank

-- 
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/CABx2%3DD9nhM0Ko0_qkbJbQr6OWu1%2Bd%3DKotS3fPV8fXhgjNxB%2BKg%40mail.gmail.com.


Re: [go-nuts] getting values from memory addresses within another process...

2020-04-30 Thread Kurtis Rader
On Thu, Apr 30, 2020 at 8:25 PM Eric Brown  wrote:

> I’ll look into this solution.  Thank you for an answer that points me in a
> possible direction.
>
> On Thu, Apr 30, 2020 at 10:24 PM Robert Engels 
> wrote:
>
>> This can be done fairly easily if you run the Go process as root and read
>> the /proc/$pid/mem pseudo file.
>>
>> On Apr 30, 2020, at 10:01 PM, Michael Jones 
>> wrote:
>>
>> 
>>
>> The general dangerous ability to do this is why protected mode went into
>> the i368 and is the first and most essential promise to prevent of every OS
>> other than MS DOS, original MacOS, and practically the threads in shared
>> memory model of Smalltalk & MP Mathematica.
>>
>> On Thu, Apr 30, 2020 at 7:13 PM Kurtis Rader 
>> wrote:
>>
>>> On Thu, Apr 30, 2020 at 6:59 PM Trig  wrote:
>>>
 I'm attempting to read memory from another process.  I've installed
 'Cheat Engine' to do this, to make sure I'm pulling the correct value from
 the address I'm attempting to; however, nothing I found works  I did find
 this article:


 https://stackoverflow.com/questions/37358478/read-random-memory-locations-with-golang

 I don't believe that is correct though, as using the address of the
 location I'm attempting to read doesn't result in a value anywhere near
 what 'Cheat Engine' is reporting.  I've looked at the 'unsafe' and
 'syscall' packages; however, there's very little information on them.
 Also, searched many ways trying to find examples on how to do this.  I'm on
 a Mac (and use Linux).  On Windows, I can do this fairly easy.

>>>
>>> Really? I'd love to see your Go code that allows reading arbitrary
>>> memory on MS Windows.
>>>
>>> As Ian pointed out on UNIX, and most operating systems for that matter,
>>> do not allow a process to read the memory of other processes without using
>>> specialized operating system APIs meant for debugging; such as the
>>> `ptrace()` syscall.
>>>
>>> Note that the stackoverflow question you linked to is bollocks. The
>>> questioner apparently wants to read the virtual memory of other processes.
>>> Yet they accepted as correct an answer that does no such thing. The
>>> "answer" only reads arbitrary virtual memory of the Go process.
>>>
>>> --
>>> Kurtis Rader
>>> Caretaker of the exceptional canines Junior and Hank
>>>
>>> --
>>> 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/CABx2%3DD9v%2BssEHjeZfV2Xb9QQYAkWgF5wskOYi2LkrfPqak4JrQ%40mail.gmail.com
>>> 
>>> .
>>>
>> --
>>
>> *Michael T. jonesmichael.jo...@gmail.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/CALoEmQw%3D1GtAw9CZVKJZ8eBhuyH2ufs%3Dg_fm6_QWU%2BSerAxYeQ%40mail.gmail.com
>> 
>> .
>>
>>

-- 
Kurtis Rader
Caretaker of the exceptional canines Junior and Hank

-- 
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/CABx2%3DD_u-Dnfoy%2BzAK9pfZ0powedUDO4q2wWV4q1pmXPg82%2B1g%40mail.gmail.com.


Re: [go-nuts] getting values from memory addresses within another process...

2020-04-30 Thread Eric Brown
I’ll look into this solution.  Thank you for an answer that points me in a
possible direction.

On Thu, Apr 30, 2020 at 10:24 PM Robert Engels 
wrote:

> This can be done fairly easily if you run the Go process as root and read
> the /proc/$pid/mem pseudo file.
>
> On Apr 30, 2020, at 10:01 PM, Michael Jones 
> wrote:
>
> 
>
> The general dangerous ability to do this is why protected mode went into
> the i368 and is the first and most essential promise to prevent of every OS
> other than MS DOS, original MacOS, and practically the threads in shared
> memory model of Smalltalk & MP Mathematica.
>
> On Thu, Apr 30, 2020 at 7:13 PM Kurtis Rader  wrote:
>
>> On Thu, Apr 30, 2020 at 6:59 PM Trig  wrote:
>>
>>> I'm attempting to read memory from another process.  I've installed
>>> 'Cheat Engine' to do this, to make sure I'm pulling the correct value from
>>> the address I'm attempting to; however, nothing I found works  I did find
>>> this article:
>>>
>>>
>>> https://stackoverflow.com/questions/37358478/read-random-memory-locations-with-golang
>>>
>>> I don't believe that is correct though, as using the address of the
>>> location I'm attempting to read doesn't result in a value anywhere near
>>> what 'Cheat Engine' is reporting.  I've looked at the 'unsafe' and
>>> 'syscall' packages; however, there's very little information on them.
>>> Also, searched many ways trying to find examples on how to do this.  I'm on
>>> a Mac (and use Linux).  On Windows, I can do this fairly easy.
>>>
>>
>> Really? I'd love to see your Go code that allows reading arbitrary memory
>> on MS Windows.
>>
>> As Ian pointed out on UNIX, and most operating systems for that matter,
>> do not allow a process to read the memory of other processes without using
>> specialized operating system APIs meant for debugging; such as the
>> `ptrace()` syscall.
>>
>> Note that the stackoverflow question you linked to is bollocks. The
>> questioner apparently wants to read the virtual memory of other processes.
>> Yet they accepted as correct an answer that does no such thing. The
>> "answer" only reads arbitrary virtual memory of the Go process.
>>
>> --
>> Kurtis Rader
>> Caretaker of the exceptional canines Junior and Hank
>>
>> --
>> 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/CABx2%3DD9v%2BssEHjeZfV2Xb9QQYAkWgF5wskOYi2LkrfPqak4JrQ%40mail.gmail.com
>> 
>> .
>>
> --
>
> *Michael T. jonesmichael.jo...@gmail.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/CALoEmQw%3D1GtAw9CZVKJZ8eBhuyH2ufs%3Dg_fm6_QWU%2BSerAxYeQ%40mail.gmail.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/CADXRNDt4w4N7%2BkUJvMcwM8SUWepUWnd3P2WVM4YWQmQAqeLhiQ%40mail.gmail.com.


Re: [go-nuts] getting values from memory addresses within another process...

2020-04-30 Thread Robert Engels
This can be done fairly easily if you run the Go process as root and read the 
/proc/$pid/mem pseudo file. 

> On Apr 30, 2020, at 10:01 PM, Michael Jones  wrote:
> 
> 
> The general dangerous ability to do this is why protected mode went into the 
> i368 and is the first and most essential promise to prevent of every OS other 
> than MS DOS, original MacOS, and practically the threads in shared memory 
> model of Smalltalk & MP Mathematica. 
> 
>> On Thu, Apr 30, 2020 at 7:13 PM Kurtis Rader  wrote:
>>> On Thu, Apr 30, 2020 at 6:59 PM Trig  wrote:
>> 
>>> I'm attempting to read memory from another process.  I've installed 'Cheat 
>>> Engine' to do this, to make sure I'm pulling the correct value from the 
>>> address I'm attempting to; however, nothing I found works  I did find this 
>>> article:
>>> 
>>> https://stackoverflow.com/questions/37358478/read-random-memory-locations-with-golang
>>> 
>>> I don't believe that is correct though, as using the address of the 
>>> location I'm attempting to read doesn't result in a value anywhere near 
>>> what 'Cheat Engine' is reporting.  I've looked at the 'unsafe' and 
>>> 'syscall' packages; however, there's very little information on them.  
>>> Also, searched many ways trying to find examples on how to do this.  I'm on 
>>> a Mac (and use Linux).  On Windows, I can do this fairly easy.
>> 
>> Really? I'd love to see your Go code that allows reading arbitrary memory on 
>> MS Windows.
>> 
>> As Ian pointed out on UNIX, and most operating systems for that matter, do 
>> not allow a process to read the memory of other processes without using 
>> specialized operating system APIs meant for debugging; such as the 
>> `ptrace()` syscall.
>> 
>> Note that the stackoverflow question you linked to is bollocks. The 
>> questioner apparently wants to read the virtual memory of other processes. 
>> Yet they accepted as correct an answer that does no such thing. The "answer" 
>> only reads arbitrary virtual memory of the Go process.
>> 
>> -- 
>> Kurtis Rader
>> Caretaker of the exceptional canines Junior and Hank
>> -- 
>> 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/CABx2%3DD9v%2BssEHjeZfV2Xb9QQYAkWgF5wskOYi2LkrfPqak4JrQ%40mail.gmail.com.
> -- 
> Michael T. Jones
> michael.jo...@gmail.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/CALoEmQw%3D1GtAw9CZVKJZ8eBhuyH2ufs%3Dg_fm6_QWU%2BSerAxYeQ%40mail.gmail.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/CF12E85C-7A85-4A20-88A3-A33C924741E5%40ix.netcom.com.


Re: [go-nuts] getting values from memory addresses within another process...

2020-04-30 Thread Eric Brown
I’m attempting to do exactly what ‘Cheat Engine’ and things like AutoHotKey
can do.  ‘Cheat Engine’ handles this just fine on all my platforms.

On Thu, Apr 30, 2020 at 10:01 PM Michael Jones 
wrote:

> The general dangerous ability to do this is why protected mode went into
> the i368 and is the first and most essential promise to prevent of every OS
> other than MS DOS, original MacOS, and practically the threads in shared
> memory model of Smalltalk & MP Mathematica.
>
> On Thu, Apr 30, 2020 at 7:13 PM Kurtis Rader  wrote:
>
>> On Thu, Apr 30, 2020 at 6:59 PM Trig  wrote:
>>
>>> I'm attempting to read memory from another process.  I've installed
>>> 'Cheat Engine' to do this, to make sure I'm pulling the correct value from
>>> the address I'm attempting to; however, nothing I found works  I did find
>>> this article:
>>>
>>>
>>> https://stackoverflow.com/questions/37358478/read-random-memory-locations-with-golang
>>>
>>> I don't believe that is correct though, as using the address of the
>>> location I'm attempting to read doesn't result in a value anywhere near
>>> what 'Cheat Engine' is reporting.  I've looked at the 'unsafe' and
>>> 'syscall' packages; however, there's very little information on them.
>>> Also, searched many ways trying to find examples on how to do this.  I'm on
>>> a Mac (and use Linux).  On Windows, I can do this fairly easy.
>>>
>>
>> Really? I'd love to see your Go code that allows reading arbitrary memory
>> on MS Windows.
>>
>> As Ian pointed out on UNIX, and most operating systems for that matter,
>> do not allow a process to read the memory of other processes without using
>> specialized operating system APIs meant for debugging; such as the
>> `ptrace()` syscall.
>>
>> Note that the stackoverflow question you linked to is bollocks. The
>> questioner apparently wants to read the virtual memory of other processes.
>> Yet they accepted as correct an answer that does no such thing. The
>> "answer" only reads arbitrary virtual memory of the Go process.
>>
>> --
>> Kurtis Rader
>> Caretaker of the exceptional canines Junior and Hank
>>
>> --
>> 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/CABx2%3DD9v%2BssEHjeZfV2Xb9QQYAkWgF5wskOYi2LkrfPqak4JrQ%40mail.gmail.com
>> 
>> .
>>
> --
>
> *Michael T. jonesmichael.jo...@gmail.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/CADXRNDsu2EneyCvNSjCsZjYRhnu4KdmWS8a7C-FmNtWj3KW4tw%40mail.gmail.com.


Re: [go-nuts] getting values from memory addresses within another process...

2020-04-30 Thread Michael Jones
The general dangerous ability to do this is why protected mode went into
the i368 and is the first and most essential promise to prevent of every OS
other than MS DOS, original MacOS, and practically the threads in shared
memory model of Smalltalk & MP Mathematica.

On Thu, Apr 30, 2020 at 7:13 PM Kurtis Rader  wrote:

> On Thu, Apr 30, 2020 at 6:59 PM Trig  wrote:
>
>> I'm attempting to read memory from another process.  I've installed
>> 'Cheat Engine' to do this, to make sure I'm pulling the correct value from
>> the address I'm attempting to; however, nothing I found works  I did find
>> this article:
>>
>>
>> https://stackoverflow.com/questions/37358478/read-random-memory-locations-with-golang
>>
>> I don't believe that is correct though, as using the address of the
>> location I'm attempting to read doesn't result in a value anywhere near
>> what 'Cheat Engine' is reporting.  I've looked at the 'unsafe' and
>> 'syscall' packages; however, there's very little information on them.
>> Also, searched many ways trying to find examples on how to do this.  I'm on
>> a Mac (and use Linux).  On Windows, I can do this fairly easy.
>>
>
> Really? I'd love to see your Go code that allows reading arbitrary memory
> on MS Windows.
>
> As Ian pointed out on UNIX, and most operating systems for that matter, do
> not allow a process to read the memory of other processes without using
> specialized operating system APIs meant for debugging; such as the
> `ptrace()` syscall.
>
> Note that the stackoverflow question you linked to is bollocks. The
> questioner apparently wants to read the virtual memory of other processes.
> Yet they accepted as correct an answer that does no such thing. The
> "answer" only reads arbitrary virtual memory of the Go process.
>
> --
> Kurtis Rader
> Caretaker of the exceptional canines Junior and Hank
>
> --
> 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/CABx2%3DD9v%2BssEHjeZfV2Xb9QQYAkWgF5wskOYi2LkrfPqak4JrQ%40mail.gmail.com
> 
> .
>
-- 

*Michael T. jonesmichael.jo...@gmail.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/CALoEmQw%3D1GtAw9CZVKJZ8eBhuyH2ufs%3Dg_fm6_QWU%2BSerAxYeQ%40mail.gmail.com.


Re: [go-nuts] Safe ways to call C with less overhead

2020-04-30 Thread Michael Jones
Function call intensity seems directly addressed by a tree or DAG like
chain of command buffers, not necessarily a full scene graph (with logic
and selection) but a call at the top and traverse tool to let you make just
a few cgo transitions to c per frame.

I’ve done this several ways myself (non-Go) and it works a charm.

On Thu, Apr 30, 2020 at 6:18 AM Constantine Shablya 
wrote:

> Thanks for reply, Ian
>
> To clear up, by safety I only mean presence of stack guards or, more
> generally,
> means of ensuring the program doesn't silently end up writing past the
> stack.
>
> From this I take my next step will be to make something between
> systemstack and
> asmcgocall so that I still run (subset of) Go while on systemstack but
> otherwise
> it would be as if it was a Cgo call, with minor difference that aligning
> stack
> and change of calling convention would happen at calls to C as opposed to
> at
> asmcgocall.
>
> --
> 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/CAEp866QQrqNUznSOFR4j_s6vW4X7ftEQVy48%3DH42UTBoe4DtXw%40mail.gmail.com
> .
>
-- 

*Michael T. jonesmichael.jo...@gmail.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/CALoEmQz6KT3zYibL7zG%2B8%3DnqQB1%3DHw0YJOcefU1_Y%3DQu6iP0AA%40mail.gmail.com.


Re: [go-nuts] getting values from memory addresses within another process...

2020-04-30 Thread Kurtis Rader
On Thu, Apr 30, 2020 at 6:59 PM Trig  wrote:

> I'm attempting to read memory from another process.  I've installed 'Cheat
> Engine' to do this, to make sure I'm pulling the correct value from the
> address I'm attempting to; however, nothing I found works  I did find this
> article:
>
>
> https://stackoverflow.com/questions/37358478/read-random-memory-locations-with-golang
>
> I don't believe that is correct though, as using the address of the
> location I'm attempting to read doesn't result in a value anywhere near
> what 'Cheat Engine' is reporting.  I've looked at the 'unsafe' and
> 'syscall' packages; however, there's very little information on them.
> Also, searched many ways trying to find examples on how to do this.  I'm on
> a Mac (and use Linux).  On Windows, I can do this fairly easy.
>

Really? I'd love to see your Go code that allows reading arbitrary memory
on MS Windows.

As Ian pointed out on UNIX, and most operating systems for that matter, do
not allow a process to read the memory of other processes without using
specialized operating system APIs meant for debugging; such as the
`ptrace()` syscall.

Note that the stackoverflow question you linked to is bollocks. The
questioner apparently wants to read the virtual memory of other processes.
Yet they accepted as correct an answer that does no such thing. The
"answer" only reads arbitrary virtual memory of the Go process.

-- 
Kurtis Rader
Caretaker of the exceptional canines Junior and Hank

-- 
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/CABx2%3DD9v%2BssEHjeZfV2Xb9QQYAkWgF5wskOYi2LkrfPqak4JrQ%40mail.gmail.com.


Re: [go-nuts] getting values from memory addresses within another process...

2020-04-30 Thread Ian Lance Taylor
On Thu, Apr 30, 2020 at 6:58 PM Trig  wrote:
>
> I'm attempting to read memory from another process.  I've installed 'Cheat 
> Engine' to do this, to make sure I'm pulling the correct value from the 
> address I'm attempting to; however, nothing I found works  I did find this 
> article:
>
> https://stackoverflow.com/questions/37358478/read-random-memory-locations-with-golang
>
> I don't believe that is correct though, as using the address of the location 
> I'm attempting to read doesn't result in a value anywhere near what 'Cheat 
> Engine' is reporting.  I've looked at the 'unsafe' and 'syscall' packages; 
> however, there's very little information on them.  Also, searched many ways 
> trying to find examples on how to do this.  I'm on a Mac (and use Linux).  On 
> Windows, I can do this fairly easy.  I can't seem to find anything that works 
> (not experienced at all in syscalls) for linux or darwin platforms.  Any help 
> appreciated.

In general Unix systems do not permit reading memory from other processes.

If you can figure out how to do it in a C program, perhaps using
ptrace, then it should be possible to figure out how to do in a Go
program.

Ian

-- 
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/CAOyqgcWr6B%2BbuduY6tyJ4bt9D9VtoE%2BkQWgcoxJwUXivp2qUkA%40mail.gmail.com.


[go-nuts] getting values from memory addresses within another process...

2020-04-30 Thread Trig
I'm attempting to read memory from another process.  I've installed 'Cheat 
Engine' to do this, to make sure I'm pulling the correct value from the 
address I'm attempting to; however, nothing I found works  I did find this 
article:

https://stackoverflow.com/questions/37358478/read-random-memory-locations-with-golang

I don't believe that is correct though, as using the address of the 
location I'm attempting to read doesn't result in a value anywhere near 
what 'Cheat Engine' is reporting.  I've looked at the 'unsafe' and 
'syscall' packages; however, there's very little information on them.  
Also, searched many ways trying to find examples on how to do this.  I'm on 
a Mac (and use Linux).  On Windows, I can do this fairly easy.  I can't 
seem to find anything that works (not experienced at all in syscalls) for 
linux or darwin platforms.  Any help appreciated.

-- 
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/7594fea8-375c-4d90-b829-67ef915444a2%40googlegroups.com.


Re: [go-nuts] URL parsing with special characters.

2020-04-30 Thread Kurtis Rader
On Thu, Apr 30, 2020 at 10:05 AM Vivek  wrote:

> I am trying to parse  a url similar to "ftp://
> user:pass@192.168.0.1/path/file%ver3.txt" using `net/url` Parse function
> but I am getting a error
>
> `parse "ftp://user:pass@192.168.0.1/path/file%ver3.txt": invalid URL
> escape "%ve"`
>

That is not a valid URL. The Python urllib.parse module explicitly ignores
invalid percent encodings and treats the % in that case as a literal
percent-sign. That URL should be written as `.../file%25ver3.txt`; assuming
you want a literal percent-sign in the path.

-- 
Kurtis Rader
Caretaker of the exceptional canines Junior and Hank

-- 
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/CABx2%3DD-oZA5x6Sjd3S-%2BKGJTbinb%3DoxrevaW3%3DcbB6cwoxKAMQ%40mail.gmail.com.


Re: [go-nuts] Re: cgo can't find .so in same directory

2020-04-30 Thread Ian Lance Taylor
On Thu, Apr 30, 2020 at 10:06 AM  wrote:
>
> https://golang.org/cmd/cgo/
> > When the cgo directives are parsed, any occurrence of the string ${SRCDIR} 
> > will be replaced by the absolute path to the directory containing the 
> > source file.
>
> So this might be what you need.
>
> #cgo LDFLAGS: -L${SRCDIR}/. -lperson

On Unix systems, the -L option sets the search path for the shared
library at link time.  It does not set the search path for the shared
library at run time.  You can set the run time search path using the
-R option.  See the system linker docs.

Ian



> On Thursday, 30 April 2020 05:19:36 UTC+1, Dean Schulze wrote:
>>
>> I'm following a simple example of using cgo to call a C library function 
>> from go.  Executing the binary gives
>>
>> error while loading shared libraries: libperson.so: cannot open shared 
>> object file: No such file or director
>>
>>
>> Here's the relevant part from the main.go file:
>>
>> /*
>> #cgo LDFLAGS: -L. -lperson
>> #include "person.h"
>>  */
>> import "C"
>>
>>
>> The file libperson.so is right in the same directory with main.go and 
>> person.h.  I've also created a soft link libperson.so.0 -> libperson.so but 
>> that doesn't have any effect.  I've tried this with go run and by go build 
>> to create a binary but both give the same error.
>>
>> Does cgo recognize the LDFLAGS: -L. symbol at all?
>>
>> What do I need to do to get a go binary to call a C function in a .so?  I 
>> really don't want to put my .so in the /usr/lib directory just to get a 
>> static linked binary for something like 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 view this discussion on the web visit 
> https://groups.google.com/d/msgid/golang-nuts/77f0e481-188f-4ec8-a621-37ff6c720cfd%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/CAOyqgcUSRrk1VQJiJC%2BJVa8O%3DY%2Btco9HszP%2BO%2BBnPnU0bhCf%2Bg%40mail.gmail.com.


Re: [go-nuts] Converting a C char[] to []byte of string with cgo

2020-04-30 Thread Dean Schulze
That works.  The problem I had earlier with a panic was caused by my C
library which was returning null as an error condition.  Once the C code
was fixed it worked as you said.

Thanks.

On Thu, Apr 30, 2020 at 2:18 PM Jan Mercl <0xj...@gmail.com> wrote:

> On Thu, Apr 30, 2020 at 10:06 PM Dean Schulze 
> wrote:
> >
> > That gives this error (which I've gotten with just about everything I
> try):
> >
> > cannot use &p.mach_name (type *[25]_Ctype_char) as type *_Ctype_char in
> argument to _Cfunc_GoString
>
> Oh yeah, should have been probably `C.GoString(&p.hostname[0])`.
> Forgot Go has stronger type discipline than C. (Not tried still.)
>

-- 
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%2BLiX6E-snRZ2hzNt6MUJ20jBez18z2HVjsfVfW4eBQZAqFR4w%40mail.gmail.com.


Re: [go-nuts] Re: URL parsing with special characters.

2020-04-30 Thread Ian Lance Taylor
On Thu, Apr 30, 2020 at 11:09 AM Brian Candler  wrote:
>
> In a URL, the percent sign should appear as %25  (% marks the start of a 
> hex-encoded character)
> https://play.golang.org/p/gMC1tdpJER4
>
> The URL as shown is invalid.

I *think* you are saying that the u.Path field should use %25 rather
than plain %.  But as the documentation says
(https://golang.org/pkg/net/url/#URL) the Path field is the decoded
form.  If you simply print the URL, you will see %25.  Consider
https://play.golang.org/p/Z0eUYfkm3PR.

If you mean something else, can you explain?  Thanks.

Ian

-- 
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/CAOyqgcXciAhj1Ommek%2B3-NYr54wqUnnAPyjk4fGg7uE45UZ_Gg%40mail.gmail.com.


Re: [go-nuts] Build fails when following build instructions

2020-04-30 Thread 'Than McIntosh' via golang-nuts
OK, that looks like a gcc as opposed to a clang. Can you please run

/usr/bin/cc -v

and show output? That will say how the gcc was configured.

There is a related LLVM bug https://bugs.llvm.org/show_bug.cgi?id=37807,
but it doesn't look as though this is a clang compiler.

Thanks



On Thu, Apr 30, 2020 at 4:39 PM Martins Eglitis 
wrote:

> Sorry, I should have mentioned that I am running a docker container based
> on the latest Ubuntu, and Ubuntu 18.04 as the host.
>
> On April 30, 2020 11:37:15 PM GMT+03:00, Martins Eglitis <
> mart...@sitilge.id.lv> wrote:
>>
>> Yes,
>>
>> cc (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0
>>
>>
>> On April 30, 2020 11:29:07 PM GMT+03:00, Than McIntosh 
>> wrote:
>>>
>>> >>/usr/bin/ld.gold: error: CMakeFiles/cmTC_81c99.dir/CheckSymbolExists.c.o:
>>> failed to match split-stack sequence at section 4 offset 0
>>>
>>> OK, now I think we're getting somewhere, this looks suspicious.  For
>>> reference, could you please send me the output of "/usr/bin/cc --version"?
>>>
>>> Thanks, Than
>>>
>>>
>>>
>>>
>>> On Thu, Apr 30, 2020 at 4:26 PM Martins Eglitis 
>>> wrote:
>>>
 Hi,

 There was something related in "CMakeError.log":

 Determining if the mmap exist failed with the following output:
 Change Dir: /home/gopher/workarea/build-debug/CMakeFiles/CMakeTmp

 Run Build Command(s):/usr/bin/ninja cmTC_81c99 && [1/2] Building C object 
 CMakeFiles/cmTC_81c99.dir/CheckSymbolExists.c.o
 CheckSymbolExists.c: In function 'main':
 CheckSymbolExists.c:8:11: warning: ISO C forbids conversion of function 
 pointer to object pointer type [-Wpedantic]
 8 |   return ((int*)(&mmap))[argc];
   |   ^
 [2/2] Linking C executable cmTC_81c99
 FAILED: cmTC_81c99
 : && /usr/bin/cc -fPIC -Werror=date-time -Wall -Wextra 
 -Wno-unused-parameter -Wwrite-strings -Wno-missing-field-initializers 
 -pedantic -Wno-long-long -Wimplicit-fallthrough -Wno-comment 
 -fdiagnostics-color -ffunction-sections -fdata-sections -fuse-ld=gold 
 -fsplit-stack  -fuse-ld=gold -Wl,-allow-shlib-undefined 
 CMakeFiles/cmTC_81c99.dir/CheckSymbolExists.c.o  -o cmTC_81c99  -lm && :
 /usr/bin/ld.gold: error: CMakeFiles/cmTC_81c99.dir/CheckSymbolExists.c.o: 
 failed to match split-stack sequence at section 4 offset 0
 collect2: error: ld returned 1 exit status
 ninja: build stopped: subcommand failed.


 File 
 /home/gopher/workarea/build-debug/CMakeFiles/CMakeTmp/CheckSymbolExists.c:
 /* */
 #include 

 int main(int argc, char** argv)
 {
   (void)argv;
 #ifndef mmap
   return ((int*)(&mmap))[argc];
 #else
   (void)argc;
   return 0;
 #endif
 }

 On 2020-04-30 20:32, Than McIntosh wrote:

 Thanks for the email.

 Sorry for the delay in responding, this is a very busy time right now
 for our team (release freeze is happening at the end of this week).

 Just in general, the gollvm build procedure uses "cmake", and as part
 of this process cmake is running various tests to make sure that the C
 compiler you're using works properly, and to detect whether the system you
 are building on has the right header files, libraries, etc.

 Of particular concern is the cmake check for "mmap"-- the mmap()
 routine is definitely available on Ubuntu, so it's puzzling that cmake
 thinks it isn't available.

 One thing you might do: after the build fails, try looking at the
 debris in the CMakeFiles dir:

 $ ls CMakeFiles
 3.13.4 cmake.check_cache  feature_tests.bin  src.c
 3.15.4 CMakeError.log feature_tests.c
  TargetDirectories.txt
 CheckIncludeFiles  CMakeOutput.logfeature_tests.cxx  test.o
 CheckTypeSize  CMakeTmp   simple.cc

 In that dir, look at "CMakeOutput.log" for the place where this test is
 run:

 Look for a section that looks like this:

 Determining if the mmap exist passed with the following output:
 Change Dir: /tmp/llvm-project/build-relwithdbg/CMakeFiles/CMakeTmp

 Run Build Command:"/usr/local/google/home/thanm/bin/ninja"
 "cmTC_feb45"
 [1/2] Building C object
 CMakeFiles/cmTC_feb45.dir/CheckSymbolExists.c.o
 CheckSymbolExists.c: In function ‘main’:
 CheckSymbolExists.c:8:11: warning: ISO C forbids conversion of
 function pointer to object pointer type [-Wpedantic]
return ((int*)(&mmap))[argc];
   ^
 [2/2] Linking C executable cmTC_feb45

 File
 /tmp/llvm-project/build-relwithdbg/CMakeFiles/CMakeTmp/CheckSymbolExists.c:
 /* */
 #include 

 int main(int argc, char** argv)
 {
   (void)argv;
 #ifndef mmap
   return ((int*)(&mmap))[argc];
 #else
   (void)argc;
   return 0;
 #endif
 }

Re: [go-nuts] Build fails when following build instructions

2020-04-30 Thread 'Martins Eglitis' via golang-nuts

Hi,

There was something related in "CMakeError.log":

Determining if the mmap exist failed with the following output:
Change Dir: /home/gopher/workarea/build-debug/CMakeFiles/CMakeTmp

Run Build Command(s):/usr/bin/ninja cmTC_81c99 && [1/2] Building C object 
CMakeFiles/cmTC_81c99.dir/CheckSymbolExists.c.o
CheckSymbolExists.c: In function 'main':
CheckSymbolExists.c:8:11: warning: ISO C forbids conversion of function pointer 
to object pointer type [-Wpedantic]
8 |   return ((int*)(&mmap))[argc];
  |   ^
[2/2] Linking C executable cmTC_81c99
FAILED: cmTC_81c99
: && /usr/bin/cc -fPIC -Werror=date-time -Wall -Wextra -Wno-unused-parameter 
-Wwrite-strings -Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough 
-Wno-comment -fdiagnostics-color -ffunction-sections -fdata-sections -fuse-ld=gold 
-fsplit-stack  -fuse-ld=gold -Wl,-allow-shlib-undefined 
CMakeFiles/cmTC_81c99.dir/CheckSymbolExists.c.o  -o cmTC_81c99  -lm && :
/usr/bin/ld.gold: error: CMakeFiles/cmTC_81c99.dir/CheckSymbolExists.c.o: 
failed to match split-stack sequence at section 4 offset 0
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.


File /home/gopher/workarea/build-debug/CMakeFiles/CMakeTmp/CheckSymbolExists.c:
/* */
#include 

int main(int argc, char** argv)
{
  (void)argv;
#ifndef mmap
  return ((int*)(&mmap))[argc];
#else
  (void)argc;
  return 0;
#endif
}

On 2020-04-30 20:32, Than McIntosh wrote:

Thanks for the email.

Sorry for the delay in responding, this is a very busy time right now 
for our team (release freeze is happening at the end of this week).


Just in general, the gollvm build procedure uses "cmake", and as part 
of this process cmake is running various tests to make sure that the C 
compiler you're using works properly, and to detect whether the system 
you are building on has the right header files, libraries, etc.


Of particular concern is the cmake check for "mmap"-- the mmap() 
routine is definitely available on Ubuntu, so it's puzzling that cmake 
thinks it isn't available.


One thing you might do: after the build fails, try looking at the 
debris in the CMakeFiles dir:


$ ls CMakeFiles
3.13.4             cmake.check_cache  feature_tests.bin  src.c
3.15.4             CMakeError.log     feature_tests.c 
 TargetDirectories.txt

CheckIncludeFiles  CMakeOutput.log    feature_tests.cxx  test.o
CheckTypeSize      CMakeTmp           simple.cc

In that dir, look at "CMakeOutput.log" for the place where this test 
is run:


Look for a section that looks like this:

    Determining if the mmap exist passed with the following output:
    Change Dir: /tmp/llvm-project/build-relwithdbg/CMakeFiles/CMakeTmp

    Run Build Command:"/usr/local/google/home/thanm/bin/ninja" 
"cmTC_feb45"
    [1/2] Building C object 
CMakeFiles/cmTC_feb45.dir/CheckSymbolExists.c.o

    CheckSymbolExists.c: In function ‘main’:
    CheckSymbolExists.c:8:11: warning: ISO C forbids conversion of 
function pointer to object pointer type [-Wpedantic]

       return ((int*)(&mmap))[argc];
      ^
    [2/2] Linking C executable cmTC_feb45

    File 
/tmp/llvm-project/build-relwithdbg/CMakeFiles/CMakeTmp/CheckSymbolExists.c:

    /* */
    #include 

    int main(int argc, char** argv)
    {
      (void)argv;
    #ifndef mmap
      return ((int*)(&mmap))[argc];
    #else
      (void)argc;
      return 0;
    #endif
    }

Are there any clues there perhaps?

Thanks, Than


On Thu, Apr 30, 2020 at 1:05 PM > wrote:


Hi,

I initially opened an issue, but was suggested to post to the
mailing list instead: https://github.com/golang/go/issues/38728

Build keeps failing when trying to build (Ubuntu Focal Fossa,
amd64) from the latest commit to the master and following the
build instructions. Has anyone succeeded to build gollvm recently?
I am getting errors like this:

|-- Could NOT find LibXml2 (missing: LIBXML2_LIBRARY
LIBXML2_INCLUDE_DIR) -- Native target architecture is X86 --
Threads enabled. -- Doxygen disabled. -- Go bindings disabled. --
Ninja version: 1.10.0 -- Could NOT find OCaml (missing: OCAMLFIND
OCAML_VERSION OCAML_STDLIB_PATH) -- Could NOT find OCaml (missing:
OCAMLFIND OCAML_VERSION OCAML_STDLIB_PATH) -- OCaml bindings
disabled. -- LLVM host triple: x86_64-unknown-linux-gnu -- LLVM
default target triple: x86_64-unknown-linux-gnu -- Building with
-fPIC -- Constructing LLVMBuild project information -- Targeting
AArch64 -- Targeting AMDGPU -- Targeting ARM -- Targeting AVR --
Targeting BPF -- Targeting Hexagon -- Targeting Lanai -- Targeting
Mips -- Targeting MSP430 -- Targeting NVPTX -- Targeting PowerPC
-- Targeting RISCV -- Targeting Sparc -- Targeting SystemZ --
Targeting WebAssembly -- Targeting X86 -- Targeting XCore CMake
Error at tools/gollvm/cmake/modules/AddGollvm.cmake:37 (message):
  C compiler does not support -fsplit-stack Call Stack (most

Re: [go-nuts] Build fails when following build instructions

2020-04-30 Thread 'Martins Eglitis' via golang-nuts
Sorry, I should have mentioned that I am running a docker container based on 
the latest Ubuntu, and Ubuntu 18.04 as the host.

On April 30, 2020 11:37:15 PM GMT+03:00, Martins Eglitis 
 wrote:
>Yes,
>
>cc (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0
>
>
>On April 30, 2020 11:29:07 PM GMT+03:00, Than McIntosh
> wrote:
/usr/bin/ld.gold: error:
>>CMakeFiles/cmTC_81c99.dir/CheckSymbolExists.c.o:
>>failed to match split-stack sequence at section 4 offset 0
>>
>>OK, now I think we're getting somewhere, this looks suspicious.  For
>>reference, could you please send me the output of "/usr/bin/cc
>>--version"?
>>
>>Thanks, Than
>>
>>
>>
>>
>>On Thu, Apr 30, 2020 at 4:26 PM Martins Eglitis
>
>>wrote:
>>
>>> Hi,
>>>
>>> There was something related in "CMakeError.log":
>>>
>>> Determining if the mmap exist failed with the following output:
>>> Change Dir: /home/gopher/workarea/build-debug/CMakeFiles/CMakeTmp
>>>
>>> Run Build Command(s):/usr/bin/ninja cmTC_81c99 && [1/2] Building C
>>object CMakeFiles/cmTC_81c99.dir/CheckSymbolExists.c.o
>>> CheckSymbolExists.c: In function 'main':
>>> CheckSymbolExists.c:8:11: warning: ISO C forbids conversion of
>>function pointer to object pointer type [-Wpedantic]
>>> 8 |   return ((int*)(&mmap))[argc];
>>>   |   ^
>>> [2/2] Linking C executable cmTC_81c99
>>> FAILED: cmTC_81c99
>>> : && /usr/bin/cc -fPIC -Werror=date-time -Wall -Wextra
>>-Wno-unused-parameter -Wwrite-strings -Wno-missing-field-initializers
>>-pedantic -Wno-long-long -Wimplicit-fallthrough -Wno-comment
>>-fdiagnostics-color -ffunction-sections -fdata-sections -fuse-ld=gold
>>-fsplit-stack  -fuse-ld=gold -Wl,-allow-shlib-undefined
>>CMakeFiles/cmTC_81c99.dir/CheckSymbolExists.c.o  -o cmTC_81c99  -lm &&
>>:
>>> /usr/bin/ld.gold: error:
>>CMakeFiles/cmTC_81c99.dir/CheckSymbolExists.c.o: failed to match
>>split-stack sequence at section 4 offset 0
>>> collect2: error: ld returned 1 exit status
>>> ninja: build stopped: subcommand failed.
>>>
>>>
>>> File
>>/home/gopher/workarea/build-debug/CMakeFiles/CMakeTmp/CheckSymbolExists.c:
>>> /* */
>>> #include 
>>>
>>> int main(int argc, char** argv)
>>> {
>>>   (void)argv;
>>> #ifndef mmap
>>>   return ((int*)(&mmap))[argc];
>>> #else
>>>   (void)argc;
>>>   return 0;
>>> #endif
>>> }
>>>
>>> On 2020-04-30 20:32, Than McIntosh wrote:
>>>
>>> Thanks for the email.
>>>
>>> Sorry for the delay in responding, this is a very busy time right
>now
>>for
>>> our team (release freeze is happening at the end of this week).
>>>
>>> Just in general, the gollvm build procedure uses "cmake", and as
>part
>>of
>>> this process cmake is running various tests to make sure that the C
>>> compiler you're using works properly, and to detect whether the
>>system you
>>> are building on has the right header files, libraries, etc.
>>>
>>> Of particular concern is the cmake check for "mmap"-- the mmap()
>>routine
>>> is definitely available on Ubuntu, so it's puzzling that cmake
>thinks
>>it
>>> isn't available.
>>>
>>> One thing you might do: after the build fails, try looking at the
>>debris
>>> in the CMakeFiles dir:
>>>
>>> $ ls CMakeFiles
>>> 3.13.4 cmake.check_cache  feature_tests.bin  src.c
>>> 3.15.4 CMakeError.log feature_tests.c
>>>  TargetDirectories.txt
>>> CheckIncludeFiles  CMakeOutput.logfeature_tests.cxx  test.o
>>> CheckTypeSize  CMakeTmp   simple.cc
>>>
>>> In that dir, look at "CMakeOutput.log" for the place where this test
>>is
>>> run:
>>>
>>> Look for a section that looks like this:
>>>
>>> Determining if the mmap exist passed with the following output:
>>> Change Dir:
>>/tmp/llvm-project/build-relwithdbg/CMakeFiles/CMakeTmp
>>>
>>> Run Build Command:"/usr/local/google/home/thanm/bin/ninja"
>>"cmTC_feb45"
>>> [1/2] Building C object
>>CMakeFiles/cmTC_feb45.dir/CheckSymbolExists.c.o
>>> CheckSymbolExists.c: In function ‘main’:
>>> CheckSymbolExists.c:8:11: warning: ISO C forbids conversion of
>>> function pointer to object pointer type [-Wpedantic]
>>>return ((int*)(&mmap))[argc];
>>>   ^
>>> [2/2] Linking C executable cmTC_feb45
>>>
>>> File
>>>
>>/tmp/llvm-project/build-relwithdbg/CMakeFiles/CMakeTmp/CheckSymbolExists.c:
>>> /* */
>>> #include 
>>>
>>> int main(int argc, char** argv)
>>> {
>>>   (void)argv;
>>> #ifndef mmap
>>>   return ((int*)(&mmap))[argc];
>>> #else
>>>   (void)argc;
>>>   return 0;
>>> #endif
>>> }
>>>
>>> Are there any clues there perhaps?
>>>
>>> Thanks, Than
>>>
>>>
>>> On Thu, Apr 30, 2020 at 1:05 PM  wrote:
>>>
 Hi,

 I initially opened an issue, but was suggested to post to the
>>mailing
 list instead: https://github.com/golang/go/issues/38728

 Build keeps failing when trying to build (Ubuntu Focal Fossa,
>amd64)
>>from
 the latest commit to the master and following the build
>>instructions. Has
 anyone succeeded to build gollvm recently? I am getting errors like
>>this:

Re: [go-nuts] Build fails when following build instructions

2020-04-30 Thread 'Martins Eglitis' via golang-nuts
Yes,

cc (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0


On April 30, 2020 11:29:07 PM GMT+03:00, Than McIntosh  wrote:
>>>/usr/bin/ld.gold: error:
>CMakeFiles/cmTC_81c99.dir/CheckSymbolExists.c.o:
>failed to match split-stack sequence at section 4 offset 0
>
>OK, now I think we're getting somewhere, this looks suspicious.  For
>reference, could you please send me the output of "/usr/bin/cc
>--version"?
>
>Thanks, Than
>
>
>
>
>On Thu, Apr 30, 2020 at 4:26 PM Martins Eglitis 
>wrote:
>
>> Hi,
>>
>> There was something related in "CMakeError.log":
>>
>> Determining if the mmap exist failed with the following output:
>> Change Dir: /home/gopher/workarea/build-debug/CMakeFiles/CMakeTmp
>>
>> Run Build Command(s):/usr/bin/ninja cmTC_81c99 && [1/2] Building C
>object CMakeFiles/cmTC_81c99.dir/CheckSymbolExists.c.o
>> CheckSymbolExists.c: In function 'main':
>> CheckSymbolExists.c:8:11: warning: ISO C forbids conversion of
>function pointer to object pointer type [-Wpedantic]
>> 8 |   return ((int*)(&mmap))[argc];
>>   |   ^
>> [2/2] Linking C executable cmTC_81c99
>> FAILED: cmTC_81c99
>> : && /usr/bin/cc -fPIC -Werror=date-time -Wall -Wextra
>-Wno-unused-parameter -Wwrite-strings -Wno-missing-field-initializers
>-pedantic -Wno-long-long -Wimplicit-fallthrough -Wno-comment
>-fdiagnostics-color -ffunction-sections -fdata-sections -fuse-ld=gold
>-fsplit-stack  -fuse-ld=gold -Wl,-allow-shlib-undefined
>CMakeFiles/cmTC_81c99.dir/CheckSymbolExists.c.o  -o cmTC_81c99  -lm &&
>:
>> /usr/bin/ld.gold: error:
>CMakeFiles/cmTC_81c99.dir/CheckSymbolExists.c.o: failed to match
>split-stack sequence at section 4 offset 0
>> collect2: error: ld returned 1 exit status
>> ninja: build stopped: subcommand failed.
>>
>>
>> File
>/home/gopher/workarea/build-debug/CMakeFiles/CMakeTmp/CheckSymbolExists.c:
>> /* */
>> #include 
>>
>> int main(int argc, char** argv)
>> {
>>   (void)argv;
>> #ifndef mmap
>>   return ((int*)(&mmap))[argc];
>> #else
>>   (void)argc;
>>   return 0;
>> #endif
>> }
>>
>> On 2020-04-30 20:32, Than McIntosh wrote:
>>
>> Thanks for the email.
>>
>> Sorry for the delay in responding, this is a very busy time right now
>for
>> our team (release freeze is happening at the end of this week).
>>
>> Just in general, the gollvm build procedure uses "cmake", and as part
>of
>> this process cmake is running various tests to make sure that the C
>> compiler you're using works properly, and to detect whether the
>system you
>> are building on has the right header files, libraries, etc.
>>
>> Of particular concern is the cmake check for "mmap"-- the mmap()
>routine
>> is definitely available on Ubuntu, so it's puzzling that cmake thinks
>it
>> isn't available.
>>
>> One thing you might do: after the build fails, try looking at the
>debris
>> in the CMakeFiles dir:
>>
>> $ ls CMakeFiles
>> 3.13.4 cmake.check_cache  feature_tests.bin  src.c
>> 3.15.4 CMakeError.log feature_tests.c
>>  TargetDirectories.txt
>> CheckIncludeFiles  CMakeOutput.logfeature_tests.cxx  test.o
>> CheckTypeSize  CMakeTmp   simple.cc
>>
>> In that dir, look at "CMakeOutput.log" for the place where this test
>is
>> run:
>>
>> Look for a section that looks like this:
>>
>> Determining if the mmap exist passed with the following output:
>> Change Dir:
>/tmp/llvm-project/build-relwithdbg/CMakeFiles/CMakeTmp
>>
>> Run Build Command:"/usr/local/google/home/thanm/bin/ninja"
>"cmTC_feb45"
>> [1/2] Building C object
>CMakeFiles/cmTC_feb45.dir/CheckSymbolExists.c.o
>> CheckSymbolExists.c: In function ‘main’:
>> CheckSymbolExists.c:8:11: warning: ISO C forbids conversion of
>> function pointer to object pointer type [-Wpedantic]
>>return ((int*)(&mmap))[argc];
>>   ^
>> [2/2] Linking C executable cmTC_feb45
>>
>> File
>>
>/tmp/llvm-project/build-relwithdbg/CMakeFiles/CMakeTmp/CheckSymbolExists.c:
>> /* */
>> #include 
>>
>> int main(int argc, char** argv)
>> {
>>   (void)argv;
>> #ifndef mmap
>>   return ((int*)(&mmap))[argc];
>> #else
>>   (void)argc;
>>   return 0;
>> #endif
>> }
>>
>> Are there any clues there perhaps?
>>
>> Thanks, Than
>>
>>
>> On Thu, Apr 30, 2020 at 1:05 PM  wrote:
>>
>>> Hi,
>>>
>>> I initially opened an issue, but was suggested to post to the
>mailing
>>> list instead: https://github.com/golang/go/issues/38728
>>>
>>> Build keeps failing when trying to build (Ubuntu Focal Fossa, amd64)
>from
>>> the latest commit to the master and following the build
>instructions. Has
>>> anyone succeeded to build gollvm recently? I am getting errors like
>this:
>>>
>>> -- Could NOT find LibXml2 (missing: LIBXML2_LIBRARY
>LIBXML2_INCLUDE_DIR)
>>> -- Native target architecture is X86
>>> -- Threads enabled.
>>> -- Doxygen disabled.
>>> -- Go bindings disabled.
>>> -- Ninja version: 1.10.0
>>> -- Could NOT find OCaml (missing: OCAMLFIND OCAML_VERSION
>OCAML_STDLIB_PATH)
>>> -- Could NOT find OCaml (missing: OCAMLFI

Re: [go-nuts] Build fails when following build instructions

2020-04-30 Thread 'Than McIntosh' via golang-nuts
>>/usr/bin/ld.gold: error: CMakeFiles/cmTC_81c99.dir/CheckSymbolExists.c.o:
failed to match split-stack sequence at section 4 offset 0

OK, now I think we're getting somewhere, this looks suspicious.  For
reference, could you please send me the output of "/usr/bin/cc --version"?

Thanks, Than




On Thu, Apr 30, 2020 at 4:26 PM Martins Eglitis 
wrote:

> Hi,
>
> There was something related in "CMakeError.log":
>
> Determining if the mmap exist failed with the following output:
> Change Dir: /home/gopher/workarea/build-debug/CMakeFiles/CMakeTmp
>
> Run Build Command(s):/usr/bin/ninja cmTC_81c99 && [1/2] Building C object 
> CMakeFiles/cmTC_81c99.dir/CheckSymbolExists.c.o
> CheckSymbolExists.c: In function 'main':
> CheckSymbolExists.c:8:11: warning: ISO C forbids conversion of function 
> pointer to object pointer type [-Wpedantic]
> 8 |   return ((int*)(&mmap))[argc];
>   |   ^
> [2/2] Linking C executable cmTC_81c99
> FAILED: cmTC_81c99
> : && /usr/bin/cc -fPIC -Werror=date-time -Wall -Wextra -Wno-unused-parameter 
> -Wwrite-strings -Wno-missing-field-initializers -pedantic -Wno-long-long 
> -Wimplicit-fallthrough -Wno-comment -fdiagnostics-color -ffunction-sections 
> -fdata-sections -fuse-ld=gold -fsplit-stack  -fuse-ld=gold 
> -Wl,-allow-shlib-undefined CMakeFiles/cmTC_81c99.dir/CheckSymbolExists.c.o  
> -o cmTC_81c99  -lm && :
> /usr/bin/ld.gold: error: CMakeFiles/cmTC_81c99.dir/CheckSymbolExists.c.o: 
> failed to match split-stack sequence at section 4 offset 0
> collect2: error: ld returned 1 exit status
> ninja: build stopped: subcommand failed.
>
>
> File 
> /home/gopher/workarea/build-debug/CMakeFiles/CMakeTmp/CheckSymbolExists.c:
> /* */
> #include 
>
> int main(int argc, char** argv)
> {
>   (void)argv;
> #ifndef mmap
>   return ((int*)(&mmap))[argc];
> #else
>   (void)argc;
>   return 0;
> #endif
> }
>
> On 2020-04-30 20:32, Than McIntosh wrote:
>
> Thanks for the email.
>
> Sorry for the delay in responding, this is a very busy time right now for
> our team (release freeze is happening at the end of this week).
>
> Just in general, the gollvm build procedure uses "cmake", and as part of
> this process cmake is running various tests to make sure that the C
> compiler you're using works properly, and to detect whether the system you
> are building on has the right header files, libraries, etc.
>
> Of particular concern is the cmake check for "mmap"-- the mmap() routine
> is definitely available on Ubuntu, so it's puzzling that cmake thinks it
> isn't available.
>
> One thing you might do: after the build fails, try looking at the debris
> in the CMakeFiles dir:
>
> $ ls CMakeFiles
> 3.13.4 cmake.check_cache  feature_tests.bin  src.c
> 3.15.4 CMakeError.log feature_tests.c
>  TargetDirectories.txt
> CheckIncludeFiles  CMakeOutput.logfeature_tests.cxx  test.o
> CheckTypeSize  CMakeTmp   simple.cc
>
> In that dir, look at "CMakeOutput.log" for the place where this test is
> run:
>
> Look for a section that looks like this:
>
> Determining if the mmap exist passed with the following output:
> Change Dir: /tmp/llvm-project/build-relwithdbg/CMakeFiles/CMakeTmp
>
> Run Build Command:"/usr/local/google/home/thanm/bin/ninja" "cmTC_feb45"
> [1/2] Building C object CMakeFiles/cmTC_feb45.dir/CheckSymbolExists.c.o
> CheckSymbolExists.c: In function ‘main’:
> CheckSymbolExists.c:8:11: warning: ISO C forbids conversion of
> function pointer to object pointer type [-Wpedantic]
>return ((int*)(&mmap))[argc];
>   ^
> [2/2] Linking C executable cmTC_feb45
>
> File
> /tmp/llvm-project/build-relwithdbg/CMakeFiles/CMakeTmp/CheckSymbolExists.c:
> /* */
> #include 
>
> int main(int argc, char** argv)
> {
>   (void)argv;
> #ifndef mmap
>   return ((int*)(&mmap))[argc];
> #else
>   (void)argc;
>   return 0;
> #endif
> }
>
> Are there any clues there perhaps?
>
> Thanks, Than
>
>
> On Thu, Apr 30, 2020 at 1:05 PM  wrote:
>
>> Hi,
>>
>> I initially opened an issue, but was suggested to post to the mailing
>> list instead: https://github.com/golang/go/issues/38728
>>
>> Build keeps failing when trying to build (Ubuntu Focal Fossa, amd64) from
>> the latest commit to the master and following the build instructions. Has
>> anyone succeeded to build gollvm recently? I am getting errors like this:
>>
>> -- Could NOT find LibXml2 (missing: LIBXML2_LIBRARY LIBXML2_INCLUDE_DIR)
>> -- Native target architecture is X86
>> -- Threads enabled.
>> -- Doxygen disabled.
>> -- Go bindings disabled.
>> -- Ninja version: 1.10.0
>> -- Could NOT find OCaml (missing: OCAMLFIND OCAML_VERSION OCAML_STDLIB_PATH)
>> -- Could NOT find OCaml (missing: OCAMLFIND OCAML_VERSION OCAML_STDLIB_PATH)
>> -- OCaml bindings disabled.
>> -- LLVM host triple: x86_64-unknown-linux-gnu
>> -- LLVM default target triple: x86_64-unknown-linux-gnu
>> -- Building with -fPIC
>> -- Constructing LLVMBuild project informa

[go-nuts] Re: Converting a C char[] to []byte of string with cgo

2020-04-30 Thread peterGo
Dean,

Command cgo
https://golang.org/cmd/cgo/#hdr-Go_references_to_C

In C, a function argument written as a fixed size array actually requires a 
pointer to the first element of the array. C compilers are aware of this 
calling convention and adjust the call accordingly, but Go cannot. In Go, 
you must pass the pointer to the first element explicitly: C.f(&C.x[0]).

Peter


On Thursday, April 30, 2020 at 2:17:37 PM UTC-4, Dean Schulze wrote:
>
> I must be missing something pretty simple, but I have a C struct like this:
>
> typedef struct line
> {
> char hostname[HOSTNAME_MAX];
> char ip[IP_MAX];
> ...
> }
>
> When I try to do the simple thing
>
> C.GoString(p.hostname)
>
> I get an error like
>
> cannot use p.hostname (type [25]_Ctype_char) as type *_Ctype_char in 
> argument to _Cfunc_GoString
>
> I've seen some examples but they all rely on *C.char and I haven't found 
> any way to get a [25]_Ctype_char to a pointer representation.
>
> What do I need to do to convert a char[] to []byte of string in Go?
>
>

-- 
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/e61da6dc-aeaf-4f13-8ba2-937e6f058943%40googlegroups.com.


Re: [go-nuts] Converting a C char[] to []byte of string with cgo

2020-04-30 Thread Dean Schulze
>
> That compiles but it still panics:
>


> test: bad machine line11=(null), return
> panic: runtime error: invalid memory address or nil pointer dereference
> [signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x4949f2]
>
> goroutine 1 [running]:
> main.(*LineStruct).MachineName(...)
>
> /home/dean/src/test.slurm.integration/test.conf.file.parser/golang/test.conf.file.parser.test.go:27
> main.main()
>
> /home/dean/src/test.slurm.integration/test.conf.file.parser/golang/test.conf.file.parser.test.go:61
> +0x52
>

-- 
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%2BLiX6HLKEW9TGpcPtoDRk3kkQYZ0PF7Cr-RCCenjfPzK3vAyg%40mail.gmail.com.


Re: [go-nuts] Converting a C char[] to []byte of string with cgo

2020-04-30 Thread Bruno Albuquerque
C.GoString((*C.char)(&p.mach_name))

On Thu, Apr 30, 2020 at 1:21 PM Dean Schulze 
wrote:

>   This expression
>
> C.GoString(C.char*(&p.mach_name))
>
> gives this error:
>
> type _Ctype_char is not an expression
>
> On Thu, Apr 30, 2020 at 2:09 PM Bruno Albuquerque  wrote:
>
>> Not pretty but if you are sure the array is zero-terminated, you can
>> simply cast it to the correct type:
>>
>> C.GoString((C.char*)(&p.hostname))
>>
>> (untested)
>>
>>
>> On Thu, Apr 30, 2020 at 1:06 PM Dean Schulze 
>> wrote:
>>
>>> That gives this error (which I've gotten with just about everything I
>>> try):
>>>
>>> cannot use &p.mach_name (type *[25]_Ctype_char) as type *_Ctype_char in
>>> argument to _Cfunc_GoString
>>>
>>> It seems to be the fixed length of the char[] that gives cgo a problem.
>>>
>>>
>>> On Thursday, April 30, 2020 at 1:46:34 PM UTC-6, Jan Mercl wrote:

 On Thu, Apr 30, 2020 at 8:17 PM Dean Schulze 
 wrote:
 >
 > I must be missing something pretty simple, but I have a C struct like
 this:
 >
 > typedef struct line
 > {
 > char hostname[HOSTNAME_MAX];
 > char ip[IP_MAX];
 > ...
 > }
 >
 > When I try to do the simple thing
 >
 > C.GoString(p.hostname)

 An array of a fixed size within a C struct is a value (the same as in
 Go), but C.GoString expects a pointer to a C.char. Try
 `C.GoString(&p.hostname)`.

 Not tested. Note that if hostname is not properly zero terminated,
 your code will crash or misbehave.

 (Automatic array decay applies to C code, but not in Go.)

>>> --
>>> 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/72d6cdaa-a6ca-4a60-b60a-a3a42de5d8d6%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/CAEd86TxG01zjZuoNmdtaR8-Zh%2BF9b4ZEjeiWm%3DAOGE1nk5OZyw%40mail.gmail.com.


Re: [go-nuts] Converting a C char[] to []byte of string with cgo

2020-04-30 Thread Dean Schulze
  This expression

C.GoString(C.char*(&p.mach_name))

gives this error:

type _Ctype_char is not an expression

On Thu, Apr 30, 2020 at 2:09 PM Bruno Albuquerque  wrote:

> Not pretty but if you are sure the array is zero-terminated, you can
> simply cast it to the correct type:
>
> C.GoString((C.char*)(&p.hostname))
>
> (untested)
>
>
> On Thu, Apr 30, 2020 at 1:06 PM Dean Schulze 
> wrote:
>
>> That gives this error (which I've gotten with just about everything I
>> try):
>>
>> cannot use &p.mach_name (type *[25]_Ctype_char) as type *_Ctype_char in
>> argument to _Cfunc_GoString
>>
>> It seems to be the fixed length of the char[] that gives cgo a problem.
>>
>>
>> On Thursday, April 30, 2020 at 1:46:34 PM UTC-6, Jan Mercl wrote:
>>>
>>> On Thu, Apr 30, 2020 at 8:17 PM Dean Schulze 
>>> wrote:
>>> >
>>> > I must be missing something pretty simple, but I have a C struct like
>>> this:
>>> >
>>> > typedef struct line
>>> > {
>>> > char hostname[HOSTNAME_MAX];
>>> > char ip[IP_MAX];
>>> > ...
>>> > }
>>> >
>>> > When I try to do the simple thing
>>> >
>>> > C.GoString(p.hostname)
>>>
>>> An array of a fixed size within a C struct is a value (the same as in
>>> Go), but C.GoString expects a pointer to a C.char. Try
>>> `C.GoString(&p.hostname)`.
>>>
>>> Not tested. Note that if hostname is not properly zero terminated,
>>> your code will crash or misbehave.
>>>
>>> (Automatic array decay applies to C code, but not in Go.)
>>>
>> --
>> 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/72d6cdaa-a6ca-4a60-b60a-a3a42de5d8d6%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%2BLiX6FpBX-Og%2BE0nVL-3NPv%2BZyD%3DbVog5QqaavoXZ%2BtunM9fg%40mail.gmail.com.


Re: [go-nuts] Converting a C char[] to []byte of string with cgo

2020-04-30 Thread Jan Mercl
On Thu, Apr 30, 2020 at 10:06 PM Dean Schulze  wrote:
>
> That gives this error (which I've gotten with just about everything I try):
>
> cannot use &p.mach_name (type *[25]_Ctype_char) as type *_Ctype_char in 
> argument to _Cfunc_GoString

Oh yeah, should have been probably `C.GoString(&p.hostname[0])`.
Forgot Go has stronger type discipline than C. (Not tried still.)

-- 
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/CAA40n-UCTF6U-fa-652vXMM_dc9AFfufZo1YQ%2BBEAniCcJp4HA%40mail.gmail.com.


[go-nuts] Re: Converting a C char[] to []byte of string with cgo

2020-04-30 Thread mike


C.GoString((*C.char)(&p.hostname))


-- 
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/dcce561b-8601-409f-8bfb-77ac7214193a%40googlegroups.com.


Re: [go-nuts] Converting a C char[] to []byte of string with cgo

2020-04-30 Thread Bruno Albuquerque
Not pretty but if you are sure the array is zero-terminated, you can simply
cast it to the correct type:

C.GoString((C.char*)(&p.hostname))

(untested)


On Thu, Apr 30, 2020 at 1:06 PM Dean Schulze 
wrote:

> That gives this error (which I've gotten with just about everything I try):
>
> cannot use &p.mach_name (type *[25]_Ctype_char) as type *_Ctype_char in
> argument to _Cfunc_GoString
>
> It seems to be the fixed length of the char[] that gives cgo a problem.
>
>
> On Thursday, April 30, 2020 at 1:46:34 PM UTC-6, Jan Mercl wrote:
>>
>> On Thu, Apr 30, 2020 at 8:17 PM Dean Schulze 
>> wrote:
>> >
>> > I must be missing something pretty simple, but I have a C struct like
>> this:
>> >
>> > typedef struct line
>> > {
>> > char hostname[HOSTNAME_MAX];
>> > char ip[IP_MAX];
>> > ...
>> > }
>> >
>> > When I try to do the simple thing
>> >
>> > C.GoString(p.hostname)
>>
>> An array of a fixed size within a C struct is a value (the same as in
>> Go), but C.GoString expects a pointer to a C.char. Try
>> `C.GoString(&p.hostname)`.
>>
>> Not tested. Note that if hostname is not properly zero terminated,
>> your code will crash or misbehave.
>>
>> (Automatic array decay applies to C code, but not in Go.)
>>
> --
> 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/72d6cdaa-a6ca-4a60-b60a-a3a42de5d8d6%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/CAEd86TznujW8f9JkyiCaNky952Nhw8t77mg1Enjixiwb_e7itA%40mail.gmail.com.


Re: [go-nuts] Converting a C char[] to []byte of string with cgo

2020-04-30 Thread Dean Schulze
That gives this error (which I've gotten with just about everything I try):

cannot use &p.mach_name (type *[25]_Ctype_char) as type *_Ctype_char in 
argument to _Cfunc_GoString

It seems to be the fixed length of the char[] that gives cgo a problem.


On Thursday, April 30, 2020 at 1:46:34 PM UTC-6, Jan Mercl wrote:
>
> On Thu, Apr 30, 2020 at 8:17 PM Dean Schulze  > wrote: 
> > 
> > I must be missing something pretty simple, but I have a C struct like 
> this: 
> > 
> > typedef struct line 
> > { 
> > char hostname[HOSTNAME_MAX]; 
> > char ip[IP_MAX]; 
> > ... 
> > } 
> > 
> > When I try to do the simple thing 
> > 
> > C.GoString(p.hostname) 
>
> An array of a fixed size within a C struct is a value (the same as in 
> Go), but C.GoString expects a pointer to a C.char. Try 
> `C.GoString(&p.hostname)`. 
>
> Not tested. Note that if hostname is not properly zero terminated, 
> your code will crash or misbehave. 
>
> (Automatic array decay applies to C code, but not in Go.) 
>

-- 
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/72d6cdaa-a6ca-4a60-b60a-a3a42de5d8d6%40googlegroups.com.


Re: [go-nuts] Converting a C char[] to []byte of string with cgo

2020-04-30 Thread Jan Mercl
On Thu, Apr 30, 2020 at 8:17 PM Dean Schulze  wrote:
>
> I must be missing something pretty simple, but I have a C struct like this:
>
> typedef struct line
> {
> char hostname[HOSTNAME_MAX];
> char ip[IP_MAX];
> ...
> }
>
> When I try to do the simple thing
>
> C.GoString(p.hostname)

An array of a fixed size within a C struct is a value (the same as in
Go), but C.GoString expects a pointer to a C.char. Try
`C.GoString(&p.hostname)`.

Not tested. Note that if hostname is not properly zero terminated,
your code will crash or misbehave.

(Automatic array decay applies to C code, but not in Go.)

-- 
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/CAA40n-X_mCYJA_SJ91d71QQFOO49vjJrUgp_SxvRnEN14HjQMQ%40mail.gmail.com.


Re: [go-nuts] Why do we use xchg rather than lock mov to inplement atomic.StoreX?

2020-04-30 Thread Keith Randall
Ah, so I guess we don't need a barrier at all on x86 for the release
semantics.
Presumably we still need something for Dekker-style algorithms, although I
don't think we use those anywhere in the stdlib, at least.
I guess it's just a question of which is faster?

On Tue, Apr 28, 2020 at 8:24 PM Cholerae Hu  wrote:

> On x86-TSO model, it seems that we don't need any mfence to archive
> acquire-release semantics. Acquire-release semantics only need compiler
> barrier to prevent compiler reordering, see https://godbolt.org/z/7JcX-d .
>
> 在 2020年4月29日星期三 UTC+8上午7:42:26,keith@gmail.com写道:
>>
>> It looks like the mechanism used by C's std::atomic would not be useful
>> for us.
>>
>> We require release semantics on atomic stores.  That is, if one thread
>> does:
>>
>> .. some other writes ...
>> atomic.StoreInt32(p, 1)
>>
>> and another thread does
>>
>> if atomic.LoadInt32(p) == 1 {
>>.. some other reads ...
>> }
>>
>> If the load sees the store, then the "other reads" must see all of the
>> "other writes". For the C atomic you cited, it does:
>>
>> regular write
>> mfence
>>
>> That doesn't provide the guarantee we need. A write before the atomic
>> could be reordered with the regular write, causing the reader to not see
>> one of the writes it was required to.
>>
>> For our use case, it would have to be
>>
>> mfence
>> regular write
>>
>> and the semantics of mfence would need to prevent write-write reorderings
>> (does it do that? Not sure.)
>>
>> We'd need some indication that changing it would be faster, as well.
>>
>> On Tuesday, April 28, 2020 at 4:03:00 AM UTC-7, Cholerae Hu wrote:
>>>
>>> But on gcc 9.3, atomic store with seq_cst order, will be compiled to
>>> mov+fence rather than xchg, see https://gcc.godbolt.org/z/ucbQt6 . Why
>>> do we use xchg rather than mov+fence in Go?
>>>
>>> 在 2020年4月28日星期二 UTC+8上午7:26:15,Ian Lance Taylor写道:

 On Sun, Apr 26, 2020 at 1:31 AM Cholerae Hu 
 wrote:
 >
 > Atomic.StoreX doesn't return the old value of the given pointer, so
 lock mov would work. Why do we use a xchg instead? It there any performance
 issue?

 I assume that you are talking about Intel processors.  Intel
 processors do not have a lock mov instruction.

 From the Intel architecture manual:

 The LOCK prefix can be prepended only to the following
 instructions and only to those forms
 of the instructions where the destination operand is a memory
 operand: ADD, ADC, AND,
 BTC, BTR, BTS, CMPXCHG, CMPXCH8B, DEC, INC, NEG, NOT, OR, SBB, SUB,
 XOR,
 XADD, and XCHG.

 Ian

>>> --
> You received this message because you are subscribed to a topic in the
> Google Groups "golang-nuts" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/golang-nuts/EbBrCk2LOaU/unsubscribe.
> To unsubscribe from this group and all its topics, 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/80d2c494-809b-47d0-bb9b-549b32068c1c%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%2BZMcON9ErhZU7_NEovAsjbrBc2ffaPaTYBzjD2nqwWBywN_%2BA%40mail.gmail.com.


[go-nuts] Re: Converting a C char[] to []byte of string with cgo

2020-04-30 Thread Dean Schulze
I've also tried this

var src [24]C.char = p.mach_ip

and this

var src *[24]C.char = &p.mach_ip

and both give panics.

>
>

-- 
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/d76baabf-58d5-4efa-9630-a95c5df28561%40googlegroups.com.


Re: [go-nuts] Using FIPS-compliant boring Go to connect to microsoft.com(specifically)

2020-04-30 Thread David Anderson
(Disclaimer: not a FIPS compliance expert, you should hire your own experts
to get authoritative answers)

FIPS 140-2 seems to reference FIPS 186-4 for specific algorithm choices.
FIPS 186-4 specifies that the RSA modulus shall be 1024, 2048, or 3072
bits. So, as-written, it seems like 4096-bit RSA keys are not allowed under
FIPS 140-2, which would explain why BoringCrypto doesn't permit them.

There seems to be a bunch of discussion in standards bodies saying that
this was a bit of a mistake in FIPS 186-4, but the great thing about
regulations is you don't fix them just by saying "oh, that's obviously
incorrect, let's just ignore it" :(

Seems like you need to talk to Azure about FIPS 140-2 compliant access
methods, or to your own compliance staff about how you can navigate the
regulatory requirements and still connect to stuff.

- Dave

On Thu, Apr 30, 2020 at 11:13 AM  wrote:

> Summary - Trying Boring Go in FIPS mode to connect to Microsoft services
> (Azure). Intermediate CA Certificate for Microsoft has a 4096 bit public
> key that is not allowed by Boring Go (Code here
> 
> ), Is there any workaround without having to turn off FIPS mode ?
>
> go version go1.14b4 linux/amd64
>
> Hi all,
> So I am working on an application that requires to be run in FIPS mode and
> has to connect to Azure services. I looked up the boring Go branch, got
> version 1.14 and started using it.
> While trying to connect to Azure services (for eg.
> graph[dot]microsoft[dot]com or even microsoft[dot]com), I was getting an
> incompatible certificate usage issue. Here is the sample code I am using -
> `package main
>
> import (
> "fmt"
> "io/ioutil"
> "net/http"
> _ "crypto/tls/fipsonly" //Code works without this but we need the 
> application to run in FIPS
> )
> func main() {
> url := "https: //microsoft.com" //Space put here because of two link 
> limit
> fmt.Printf("HTML code of %s ...\n", url)
> client := &http.Client{}
> resp, err := client.Get(url)
>
> if err != nil {
> panic(err)
> }
>
> defer resp.Body.Close()
>
> html, err := ioutil.ReadAll(resp.Body)
> if err != nil {
> panic(err)
> }
>
> fmt.Printf("%s\n", html)
> }`
>
> The error I get is as follows -
> HTML code of https: //microsoft.com ... panic: Get "https: //microsoft.com":
> x509: certificate specifies an incompatible key usage goroutine 1
> [running]: main.main() /usr/local/go/bin/test.go:15 +0x26c exit status 2
>
> I checked the golang code and found that a certificate with a 4096 bit
> public key is not a valid certificate according to the IsBoringCertificate
> function The intermediate certificate in Microsoft’s Certificate Chain has
> a 4096 bit public key.
> [image: Screen Shot 2020-04-27 at 12.35.20 PM]
> 
>
> So, my question is as follows :
>
>1. Is this intended behavior ?
>2. If yes, is here any workaround via which I can keep FIPS mode on
>and connect to these services ? This workaround can be code changes or
>using different tools. However, I can’t turn off FIPS mode.
>
> Thanks for going through 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/golang-nuts/619f65bc-e79a-4412-8913-a03992fae04a%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/CAMx%2Br7WOU4-%2BVweYrep2dcCkhirgV9JiV3ct42k70fBtL73wcw%40mail.gmail.com.


[go-nuts] Converting a C char[] to []byte of string with cgo

2020-04-30 Thread Dean Schulze
I must be missing something pretty simple, but I have a C struct like this:

typedef struct line
{
char hostname[HOSTNAME_MAX];
char ip[IP_MAX];
...
}

When I try to do the simple thing

C.GoString(p.hostname)

I get an error like

cannot use p.hostname (type [25]_Ctype_char) as type *_Ctype_char in 
argument to _Cfunc_GoString

I've seen some examples but they all rely on *C.char and I haven't found 
any way to get a [25]_Ctype_char to a pointer representation.

What do I need to do to convert a char[] to []byte of string in Go?

-- 
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/3a27c19c-7d96-4a5c-afc2-61f42215b2e2%40googlegroups.com.


[go-nuts] Using FIPS-compliant boring Go to connect to microsoft.com(specifically)

2020-04-30 Thread mohit . bits2011


Summary - Trying Boring Go in FIPS mode to connect to Microsoft services 
(Azure). Intermediate CA Certificate for Microsoft has a 4096 bit public 
key that is not allowed by Boring Go (Code here 

 
), Is there any workaround without having to turn off FIPS mode ?

go version go1.14b4 linux/amd64

Hi all,
So I am working on an application that requires to be run in FIPS mode and 
has to connect to Azure services. I looked up the boring Go branch, got 
version 1.14 and started using it.
While trying to connect to Azure services (for eg. 
graph[dot]microsoft[dot]com or even microsoft[dot]com), I was getting an 
incompatible certificate usage issue. Here is the sample code I am using -
`package main

import (
"fmt"
"io/ioutil"
"net/http"
_ "crypto/tls/fipsonly" //Code works without this but we need the 
application to run in FIPS
)
func main() {
url := "https: //microsoft.com" //Space put here because of two link 
limit
fmt.Printf("HTML code of %s ...\n", url)
client := &http.Client{}
resp, err := client.Get(url)

if err != nil {
panic(err)
}
   
defer resp.Body.Close()

html, err := ioutil.ReadAll(resp.Body)
if err != nil {
panic(err)
}

fmt.Printf("%s\n", html)
}`

The error I get is as follows -
HTML code of https: //microsoft.com ... panic: Get "https: 
//microsoft.com": x509: certificate specifies an incompatible key usage 
goroutine 1 [running]: main.main() /usr/local/go/bin/test.go:15 +0x26c exit 
status 2

I checked the golang code and found that a certificate with a 4096 bit 
public key is not a valid certificate according to the IsBoringCertificate 
function The intermediate certificate in Microsoft’s Certificate Chain has 
a 4096 bit public key.
[image: Screen Shot 2020-04-27 at 12.35.20 PM] 


So, my question is as follows :

   1. Is this intended behavior ?
   2. If yes, is here any workaround via which I can keep FIPS mode on and 
   connect to these services ? This workaround can be code changes or using 
   different tools. However, I can’t turn off FIPS mode.

Thanks for going through 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 view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/619f65bc-e79a-4412-8913-a03992fae04a%40googlegroups.com.


[go-nuts] Re: URL parsing with special characters.

2020-04-30 Thread Brian Candler
In a URL, the percent sign should appear as %25  (% marks the start of a 
hex-encoded character)
https://play.golang.org/p/gMC1tdpJER4

The URL as shown is invalid.

-- 
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/5b4461d5-d635-430c-8a7c-95277364773f%40googlegroups.com.


Re: [go-nuts] Build fails when following build instructions

2020-04-30 Thread 'Than McIntosh' via golang-nuts
Thanks for the email.

Sorry for the delay in responding, this is a very busy time right now for
our team (release freeze is happening at the end of this week).

Just in general, the gollvm build procedure uses "cmake", and as part of
this process cmake is running various tests to make sure that the C
compiler you're using works properly, and to detect whether the system you
are building on has the right header files, libraries, etc.

Of particular concern is the cmake check for "mmap"-- the mmap() routine is
definitely available on Ubuntu, so it's puzzling that cmake thinks it isn't
available.

One thing you might do: after the build fails, try looking at the debris in
the CMakeFiles dir:

$ ls CMakeFiles
3.13.4 cmake.check_cache  feature_tests.bin  src.c
3.15.4 CMakeError.log feature_tests.c
 TargetDirectories.txt
CheckIncludeFiles  CMakeOutput.logfeature_tests.cxx  test.o
CheckTypeSize  CMakeTmp   simple.cc

In that dir, look at "CMakeOutput.log" for the place where this test is run:

Look for a section that looks like this:

Determining if the mmap exist passed with the following output:
Change Dir: /tmp/llvm-project/build-relwithdbg/CMakeFiles/CMakeTmp

Run Build Command:"/usr/local/google/home/thanm/bin/ninja" "cmTC_feb45"
[1/2] Building C object CMakeFiles/cmTC_feb45.dir/CheckSymbolExists.c.o
CheckSymbolExists.c: In function ‘main’:
CheckSymbolExists.c:8:11: warning: ISO C forbids conversion of function
pointer to object pointer type [-Wpedantic]
   return ((int*)(&mmap))[argc];
  ^
[2/2] Linking C executable cmTC_feb45

File
/tmp/llvm-project/build-relwithdbg/CMakeFiles/CMakeTmp/CheckSymbolExists.c:
/* */
#include 

int main(int argc, char** argv)
{
  (void)argv;
#ifndef mmap
  return ((int*)(&mmap))[argc];
#else
  (void)argc;
  return 0;
#endif
}

Are there any clues there perhaps?

Thanks, Than


On Thu, Apr 30, 2020 at 1:05 PM  wrote:

> Hi,
>
> I initially opened an issue, but was suggested to post to the mailing list
> instead: https://github.com/golang/go/issues/38728
>
> Build keeps failing when trying to build (Ubuntu Focal Fossa, amd64) from
> the latest commit to the master and following the build instructions. Has
> anyone succeeded to build gollvm recently? I am getting errors like this:
>
> -- Could NOT find LibXml2 (missing: LIBXML2_LIBRARY LIBXML2_INCLUDE_DIR)
> -- Native target architecture is X86
> -- Threads enabled.
> -- Doxygen disabled.
> -- Go bindings disabled.
> -- Ninja version: 1.10.0
> -- Could NOT find OCaml (missing: OCAMLFIND OCAML_VERSION OCAML_STDLIB_PATH)
> -- Could NOT find OCaml (missing: OCAMLFIND OCAML_VERSION OCAML_STDLIB_PATH)
> -- OCaml bindings disabled.
> -- LLVM host triple: x86_64-unknown-linux-gnu
> -- LLVM default target triple: x86_64-unknown-linux-gnu
> -- Building with -fPIC
> -- Constructing LLVMBuild project information
> -- Targeting AArch64
> -- Targeting AMDGPU
> -- Targeting ARM
> -- Targeting AVR
> -- Targeting BPF
> -- Targeting Hexagon
> -- Targeting Lanai
> -- Targeting Mips
> -- Targeting MSP430
> -- Targeting NVPTX
> -- Targeting PowerPC
> -- Targeting RISCV
> -- Targeting Sparc
> -- Targeting SystemZ
> -- Targeting WebAssembly
> -- Targeting X86
> -- Targeting XCore
> CMake Error at tools/gollvm/cmake/modules/AddGollvm.cmake:37 (message):
>   C compiler does not support -fsplit-stack
> Call Stack (most recent call first):
>   tools/gollvm/CMakeLists.txt:21 (include)
>
>
> -- starting libgo configuration.
> CMake Error at tools/gollvm/cmake/modules/LibbacktraceUtils.cmake:19 
> (message):
>   Support for mmap() is required -- setup failed.
> Call Stack (most recent call first):
>   tools/gollvm/libgo/CMakeLists.txt:45 (setup_libbacktrace)
>
>
> CMake Error at tools/gollvm/cmake/modules/LibffiUtils.cmake:27 (message):
>   Support for mmap() is required -- setup failed.
> Call Stack (most recent call first):
>   tools/gollvm/libgo/CMakeLists.txt:49 (setup_libffi)
>
>
> -- Libgo: creating stdlib package targets
> -- Libgo: generating check targets
> -- libgo configuration complete.
> -- starting gotools configuration.
> -- gotools: generating check targets
> -- gotools configuration complete.
> -- Registering Bye as a pass plugin (static build: OFF)
> -- Failed to find LLVM FileCheck
> -- Version: 0.0.0
> -- Performing Test HAVE_GNU_POSIX_REGEX -- failed to compile
> -- Performing Test HAVE_POSIX_REGEX -- success
> -- Performing Test HAVE_STEADY_CLOCK -- success
> -- Configuring incomplete, errors occurred!
> See also "/home/gopher/workarea/build-debug/CMakeFiles/CMakeOutput.log".
> See also "/home/gopher/workarea/build-debug/CMakeFiles/CMakeError.log".
> ninja: error: loading 'build.ninja': No such file or directory
>
>
>
> --
> 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 g

[go-nuts] Re: cgo can't find .so in same directory

2020-04-30 Thread mike
https://golang.org/cmd/cgo/
> When the cgo directives are parsed, any occurrence of the string 
${SRCDIR} will be replaced by the absolute path to the directory containing 
the source file.

So this might be what you need.

#cgo LDFLAGS: -L${SRCDIR}/. -lperson


On Thursday, 30 April 2020 05:19:36 UTC+1, Dean Schulze wrote:
>
> I'm following a simple example 
>  of using 
> cgo to call a C library function from go.  Executing the binary gives
>
> error while loading shared libraries: libperson.so: cannot open shared 
> object file: No such file or director
>
>
> Here's the relevant part from the main.go file:
>
> /*
> #cgo LDFLAGS: -L. -lperson
> #include "person.h"
>  */
> import "C"
>
>
> The file libperson.so is right in the same directory with main.go and 
> person.h.  I've also created a soft link libperson.so.0 -> libperson.so but 
> that doesn't have any effect.  I've tried this with go run and by go build 
> to create a binary but both give the same error.
>
> Does cgo recognize the LDFLAGS: -L. symbol at all?
>
> What do I need to do to get a go binary to call a C function in a .so?  I 
> really don't want to put my .so in the /usr/lib directory just to get a 
> static linked binary for something like 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 view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/77f0e481-188f-4ec8-a621-37ff6c720cfd%40googlegroups.com.


[go-nuts] URL parsing with special characters.

2020-04-30 Thread Vivek
I am trying to parse  a url similar to "f
tp://user:pass@192.168.0.1/path/file%ver3.txt" using `net/url` Parse 
function but I am getting a error

`parse "ftp://user:pass@192.168.0.1/path/file%ver3.txt": invalid URL escape 
"%ve"`

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


The same path parses fine with python(urllib.parse.urlparse and C# URI). 

I appreciate any help on this.

Regards,
Vivek

-- 
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/dc71e90a-222b-4e8a-a246-99ee33634260%40googlegroups.com.


[go-nuts] Is there a library for validating gmail's Variants

2020-04-30 Thread Walter Peng

Hello community,

We are running a small website which allow users registration with their
email.

Many users use gmail's variants to sign up the site, as we know,
foo...@gmail.com is equivalent to below similar:

foo...@googlemail.com
foob...@googlemail.com
foo@gmail.com
foobar+...@gmail.com
foo.bar+m...@gmail.com
...

Is there a library existing to validate all those variants to make sure
they are exactly the same account?

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/313e1c4b-6bcb-d010-e841-9c544048bc13%40web.de.


[go-nuts] Build fails when following build instructions

2020-04-30 Thread sitilge
Hi,

I initially opened an issue, but was suggested to post to the mailing list 
instead: https://github.com/golang/go/issues/38728

Build keeps failing when trying to build (Ubuntu Focal Fossa, amd64) from 
the latest commit to the master and following the build instructions. Has 
anyone succeeded to build gollvm recently? I am getting errors like this:

-- Could NOT find LibXml2 (missing: LIBXML2_LIBRARY LIBXML2_INCLUDE_DIR) 
-- Native target architecture is X86
-- Threads enabled.
-- Doxygen disabled.
-- Go bindings disabled.
-- Ninja version: 1.10.0
-- Could NOT find OCaml (missing: OCAMLFIND OCAML_VERSION OCAML_STDLIB_PATH) 
-- Could NOT find OCaml (missing: OCAMLFIND OCAML_VERSION OCAML_STDLIB_PATH) 
-- OCaml bindings disabled.
-- LLVM host triple: x86_64-unknown-linux-gnu
-- LLVM default target triple: x86_64-unknown-linux-gnu
-- Building with -fPIC
-- Constructing LLVMBuild project information
-- Targeting AArch64
-- Targeting AMDGPU
-- Targeting ARM
-- Targeting AVR
-- Targeting BPF
-- Targeting Hexagon
-- Targeting Lanai
-- Targeting Mips
-- Targeting MSP430
-- Targeting NVPTX
-- Targeting PowerPC
-- Targeting RISCV
-- Targeting Sparc
-- Targeting SystemZ
-- Targeting WebAssembly
-- Targeting X86
-- Targeting XCore
CMake Error at tools/gollvm/cmake/modules/AddGollvm.cmake:37 (message):
  C compiler does not support -fsplit-stack
Call Stack (most recent call first):
  tools/gollvm/CMakeLists.txt:21 (include)


-- starting libgo configuration.
CMake Error at tools/gollvm/cmake/modules/LibbacktraceUtils.cmake:19 (message):
  Support for mmap() is required -- setup failed.
Call Stack (most recent call first):
  tools/gollvm/libgo/CMakeLists.txt:45 (setup_libbacktrace)


CMake Error at tools/gollvm/cmake/modules/LibffiUtils.cmake:27 (message):
  Support for mmap() is required -- setup failed.
Call Stack (most recent call first):
  tools/gollvm/libgo/CMakeLists.txt:49 (setup_libffi)


-- Libgo: creating stdlib package targets
-- Libgo: generating check targets
-- libgo configuration complete.
-- starting gotools configuration.
-- gotools: generating check targets
-- gotools configuration complete.
-- Registering Bye as a pass plugin (static build: OFF)
-- Failed to find LLVM FileCheck
-- Version: 0.0.0
-- Performing Test HAVE_GNU_POSIX_REGEX -- failed to compile
-- Performing Test HAVE_POSIX_REGEX -- success
-- Performing Test HAVE_STEADY_CLOCK -- success
-- Configuring incomplete, errors occurred!
See also "/home/gopher/workarea/build-debug/CMakeFiles/CMakeOutput.log".
See also "/home/gopher/workarea/build-debug/CMakeFiles/CMakeError.log".
ninja: error: loading 'build.ninja': No such file or directory



-- 
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/cdb72cf2-2fe2-4f44-87fb-5cc2058dd58a%40googlegroups.com.


[go-nuts] Getting the latest non-tagged version of main module

2020-04-30 Thread Shulhan
Sometimes when I push too fast on one of dependencies, the Go proxy can't
catch up the latest non-tagged commit on remote server.  So, I need to get the
latest module version on tip of git commit using the following shell script,


#!/bin/sh

MODNAME=$(go list -m)
DATE=$(date -u -r `git log -n 1 --date=local --pretty=format:'%ct'` 
+%Y%0m%0d%0H%0M%0S)
HASH=$(git log -n 1 --pretty=format:'%h' --abbrev=12)
TAG=$(git describe --abbrev=0 --tags 2>/dev/null)

if [[ "${TAG}" == "" ]]; then
TAG="v0.0.0"
else
IFS=. read MAJOR MINOR PATCH <<<"${TAG}"
PATCH=$((PATCH+1))
TAG=${MAJOR}.${MINOR}.${PATCH}
fi

echo ${MODNAME} ${TAG}-${DATE}-${HASH}


and update the version on go.mod manually to force the proxy to get the
defined version.  I know that I should test and maybe use "replace" directive
before committing any changes to one of dependencies, but one or two things
sometimes slip out of our eyes.

I have read the documentation on "go help list" and search the web for any
alternatives, unfortunately I can't find one.  If anyone have any idea about
go command that can replace above script, that would be great.


Regards,

Shulhan

-- 
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/949F7DDA-0FDC-424F-96B3-79EA49695726%40gmail.com.


[go-nuts] Re: cgo can't find .so in same directory

2020-04-30 Thread Dean Schulze
That was it.  It's actually 
export LD_LIBRARY_PATH=${PWD}



On Thursday, April 30, 2020 at 1:05:58 AM UTC-6, Miki Tebeka wrote:
>
> IMO the #cgo directive is just building the executable, not for running it.
> You can set the LD_LIBRARY_PATH environment variable before running the 
> exeutable
> LD_LIBRARY_PATH=${PWD} ./app
>
>
> On Thursday, April 30, 2020 at 7:19:36 AM UTC+3, Dean Schulze wrote:
>>
>> I'm following a simple example 
>>  of 
>> using cgo to call a C library function from go.  Executing the binary gives
>>
>> error while loading shared libraries: libperson.so: cannot open shared 
>> object file: No such file or director
>>
>>
>> Here's the relevant part from the main.go file:
>>
>> /*
>> #cgo LDFLAGS: -L. -lperson
>> #include "person.h"
>>  */
>> import "C"
>>
>>
>> The file libperson.so is right in the same directory with main.go and 
>> person.h.  I've also created a soft link libperson.so.0 -> libperson.so but 
>> that doesn't have any effect.  I've tried this with go run and by go build 
>> to create a binary but both give the same error.
>>
>> Does cgo recognize the LDFLAGS: -L. symbol at all?
>>
>> What do I need to do to get a go binary to call a C function in a .so?  I 
>> really don't want to put my .so in the /usr/lib directory just to get a 
>> static linked binary for something like this.
>>
> $ LD_LIBRARY_PATH=${PWD} ./app
>

-- 
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/2722055f-2a07-4605-bb01-3f544f362b2e%40googlegroups.com.


Re: [go-nuts] Safe ways to call C with less overhead

2020-04-30 Thread Constantine Shablya
Thanks for reply, Ian

To clear up, by safety I only mean presence of stack guards or, more generally,
means of ensuring the program doesn't silently end up writing past the stack.

>From this I take my next step will be to make something between systemstack and
asmcgocall so that I still run (subset of) Go while on systemstack but otherwise
it would be as if it was a Cgo call, with minor difference that aligning stack
and change of calling convention would happen at calls to C as opposed to at
asmcgocall.

-- 
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/CAEp866QQrqNUznSOFR4j_s6vW4X7ftEQVy48%3DH42UTBoe4DtXw%40mail.gmail.com.


Re: [go-nuts] json decode is very slow

2020-04-30 Thread Sarath Prabath Redlapalli Jaya
Thanks Amnon & Hi Jesper,

You're correct. Most of the time is actually spent in *ioutil.ReadAll()* .
Trying to debug network issues related to GCP, GKE & the functionality of
ISTIO sidecar reverse proxy, but seems okay so far couldn't find anything.

But, I've performed an interesting experiment.

Tried the same API in Ruby with Sinatra by mirroring the traffic. When
instrumented the API Response Times, all were <= 100 ms. Any clues on how
to debug this?I can't seem to find much on inner workings of
http.Request.Body -> io.ReadCloser

Also, If we're are looking for flaky end-user connections i.e., mobile
wireless devices etc., the connection termination is at reverse proxy
itself and the lag in reading request shouldn't be observed at the
application level. Correct me if I'm wrong.

Regards

On Thu, Apr 30, 2020 at 2:34 PM Jesper Louis Andersen <
jesper.louis.ander...@gmail.com> wrote:

> On Tue, Apr 28, 2020 at 6:48 PM Sarath Prabath Redlapalli Jaya <
> harrysarath2...@gmail.com> wrote:
>
>> We've instrument the above code block and reading request body bytes is 
>> taking very long i.e., upto 5 secs sometimes reaching upto 20 seconds at the 
>> throughput of ~4-5K RPM
>>
>>
>> The Request Body Size Metrics are as follows
>>
>> Average: 73190 Bytes
>> 90th percentile: 170862 Bytes
>> 99th percentile: 467638 Bytes
>>
>>
> Let us assume we have 500 kilobytes of data. At 20 seconds processing
> time, you are looking at something like 25 bytes per millisecond, which
> seems rather low for a decent CPU. Try measuring the time it takes to
> ioutil.ReadAll from the Reader I assume you have access to. My hunch is you
> are spending most of the time there, and relatively little on decoding the
> JSON data you have. Once you've done this, you will have some more
> knowledge of where to look: the network, or the JSON decoder.
>
> If this is a web request, you should also look at how time it takes the
> other end to feed data to the GCP process. Chances are that the problem is
> in the other end, and you are looking at a slow sender, especially if you
> have a large set of mobile devices out there with variety in their internet
> connections.
>
>

-- 
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/CADOH-f9mhKy0e3B9exCe8P3BNmgO5OMCXwGsNN1VjWSg3ofNqQ%40mail.gmail.com.


Re: [go-nuts] json decode is very slow

2020-04-30 Thread Jesper Louis Andersen
On Tue, Apr 28, 2020 at 6:48 PM Sarath Prabath Redlapalli Jaya <
harrysarath2...@gmail.com> wrote:

> We've instrument the above code block and reading request body bytes is 
> taking very long i.e., upto 5 secs sometimes reaching upto 20 seconds at the 
> throughput of ~4-5K RPM
>
>
> The Request Body Size Metrics are as follows
>
> Average: 73190 Bytes
> 90th percentile: 170862 Bytes
> 99th percentile: 467638 Bytes
>
>
Let us assume we have 500 kilobytes of data. At 20 seconds processing time,
you are looking at something like 25 bytes per millisecond, which seems
rather low for a decent CPU. Try measuring the time it takes to
ioutil.ReadAll from the Reader I assume you have access to. My hunch is you
are spending most of the time there, and relatively little on decoding the
JSON data you have. Once you've done this, you will have some more
knowledge of where to look: the network, or the JSON decoder.

If this is a web request, you should also look at how time it takes the
other end to feed data to the GCP process. Chances are that the problem is
in the other end, and you are looking at a slow sender, especially if you
have a large set of mobile devices out there with variety in their internet
connections.

-- 
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/CAGrdgiWYeMuFvV-kO4kYDQbVHKCHKw%3D4A13PSPKCywiDfn2L%3DQ%40mail.gmail.com.


[go-nuts] Re: json decode is very slow

2020-04-30 Thread Amnon Baron Cohen
encoding/json is quite old and not particularly fast.
There are some other implementations  around which use code generation
rather than reflection, and which claim to give a speedup of 3x or meore

I would try one of them:
https://github.com/mailru/easyjson
or https://github.com/pquerna/ffjson

On Tuesday, 28 April 2020 17:49:08 UTC+1, Sarath Prabath Redlapalli Jaya 
wrote:
>
> req := &mystruct{}
> json.NewDecoder(r.Body).Decode(req)
>
>
> We've instrument the above code block and reading request body bytes is 
> taking very long i.e., upto 5 secs sometimes reaching upto 20 seconds at 
> the throughput of ~4-5K RPM
>
> The Request Body Size Metrics are as follows
>
> Average: 73190 Bytes
> 90th percentile: 170862 Bytes
> 99th percentile: 467638 Bytes
>
> Tried ioutil.ReadAll too. But, the read time is same. We're not sure why 
> it's so very slow on production with HIGH BANDWIDTH Network line.
>
> Also, there are 5% of errors in this API with following errors while 
> decoding json data
>
>1. unexpected EOF
>2. Error in decoding request: read tcp 127.0.0.1:8080->127.0.0.1:48896: 
>i/o timeout
>
> We're using Kubernetes with Istio 1.0.5 on GCP. These errors are probably 
> from Envoy Sidecar, but since the Envoy acts as a reverse proxy, not sure 
> why we can get EOF or Timeout Errors since end user connection terminates 
> at proxy itself.
>

-- 
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/65271a8e-ee33-4d9f-9eec-8a4f9c53fc99%40googlegroups.com.


Re: [go-nuts] Store function name as JSON?

2020-04-30 Thread Brian Candler
Or initialize a map with your functions, and lookup in the map.

-- 
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/c8b42111-fa1a-4649-8400-209323941046%40googlegroups.com.


[go-nuts] About text-based user interface for Windows and Linux

2020-04-30 Thread 洪嘉鴻
Hello everyone:
I use golang with Win10.
I want to make some text-based user interface executables for Windows and 
Linux.
There are sure many libraries about text-based user interface, such as 
tcell, termbox, gocui, termui, tui, tview, and so on.
However, the boxes and some words are cut while executing.
The followings are the pictures which execute "tview" on Windows and 
Linux(VMware Ubuntu 18.04).

[image: Windows.PNG] [image: VMware (Ubuntu).PNG] 

The problem always happen while executing on Windows whatever using any 
libraries mentioned above, while some happen while executing on Linux.
I have no idea what causes the results.
Does anyone know why and how to solve?


Any help is appreciated.
Thank you very much!
Max

-- 
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/bf1c045d-160d-4841-9da3-d50a8f857584%40googlegroups.com.


[go-nuts] Re: cgo can't find .so in same directory

2020-04-30 Thread Miki Tebeka
IMO the #cgo directive is just building the executable, not for running it.
You can set the LD_LIBRARY_PATH environment variable before running the 
exeutable
LD_LIBRARY_PATH=${PWD} ./app


On Thursday, April 30, 2020 at 7:19:36 AM UTC+3, Dean Schulze wrote:
>
> I'm following a simple example 
>  of using 
> cgo to call a C library function from go.  Executing the binary gives
>
> error while loading shared libraries: libperson.so: cannot open shared 
> object file: No such file or director
>
>
> Here's the relevant part from the main.go file:
>
> /*
> #cgo LDFLAGS: -L. -lperson
> #include "person.h"
>  */
> import "C"
>
>
> The file libperson.so is right in the same directory with main.go and 
> person.h.  I've also created a soft link libperson.so.0 -> libperson.so but 
> that doesn't have any effect.  I've tried this with go run and by go build 
> to create a binary but both give the same error.
>
> Does cgo recognize the LDFLAGS: -L. symbol at all?
>
> What do I need to do to get a go binary to call a C function in a .so?  I 
> really don't want to put my .so in the /usr/lib directory just to get a 
> static linked binary for something like this.
>
$ LD_LIBRARY_PATH=${PWD} ./app

-- 
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/c2e7899f-beb1-4946-af63-0846c8217301%40googlegroups.com.