Re: [go-nuts] Cross compiling for linux from dawin

2020-09-22 Thread Joop Kiefte
Quick guess, the dependencies the CGo in that library tries to link with are 
not the correct version and as such lack some definitions? Try updating the C 
dependency source if possible to a later or corresponding version, if that 
makes sense?

[Joop Kiefte - Chat @ 
Spike](https://spikenow.com/r/a/?ref=spike-organic-signature&_ts=p2cv3)   
[p2cv3]

On September 22, 2020 at 22:53 GMT, Mixo Ndleve  wrote:

FiloSottile/musl-cross/musl-cross is set up. 
(https://subscription.packtpub.com/book/application_development/9781789138412/app02/app02lvl1sec98/cross-compiling-for-linux-with-cgo)

With it we are able to cross compile for windows and linux from darwin, the 
problem arises as soon as we import _ "github.com/cvigo/go_ibm_db"

On Tue, Sep 22, 2020 at 9:46 PM Marcin Romaszewicz  wrote:

Your compiler environment for C code is still building for Darwin, most likely. 
You need to set up a cross compiler and use cgo (https://golang.org/cmd/cgo/). 
$CC should invoke your cross compiler.

On Tue, Sep 22, 2020 at 11:19 AM Mixo Ndleve  wrote:

Experiencing this problem when "github.com/cvigo/go_ibm_db" is imported

../../../go/pkg/mod/github.com/lunny/godbc@v0.0.0-20131220142036-57f94ee1eb13/api/api.go:13:9:
 undefined: SQLSMALLINT
../../../go/pkg/mod/github.com/lunny/godbc@v0.0.0-20131220142036-57f94ee1eb13/api/api.go:14:9:
 undefined: SQLUSMALLINT
../../../go/pkg/mod/github.com/lunny/godbc@v0.0.0-20131220142036-57f94ee1eb13/api/api.go:15:9:
 undefined: SQLUSMALLINT
../../../go/pkg/mod/github.com/lunny/godbc@v0.0.0-20131220142036-57f94ee1eb13/api/api.go:19:12:
 undefined: SQLSMALLINT
../../../go/pkg/mod/github.com/lunny/godbc@v0.0.0-20131220142036-57f94ee1eb13/api/api.go:20:12:
 undefined: SQLUSMALLINT
../../../go/pkg/mod/github.com/lunny/godbc@v0.0.0-20131220142036-57f94ee1eb13/api/api.go:21:12:
 undefined: SQLUSMALLINT
../../../go/pkg/mod/github.com/lunny/godbc@v0.0.0-20131220142036-57f94ee1eb13/api/api.go:22:12:
 undefined: SQLUSMALLINT
../../../go/pkg/mod/github.com/lunny/godbc@v0.0.0-20131220142036-57f94ee1eb13/api/api.go:23:12:
 undefined: SQLUSMALLINT
../../../go/pkg/mod/github.com/lunny/godbc@v0.0.0-20131220142036-57f94ee1eb13/api/api.go:24:12:
 undefined: SQLUSMALLINT
../../../go/pkg/mod/github.com/lunny/godbc@v0.0.0-20131220142036-57f94ee1eb13/api/api.go:25:12:
 undefined: SQLUINTEGER
../../../go/pkg/mod/github.com/lunny/godbc@v0.0.0-20131220142036-57f94ee1eb13/api/api.go:25:12:
 too many errors

--
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/bd1c2b60-8459-46d8-a022-0527f0fba150n%40googlegroups.com](https://groups.google.com/d/msgid/golang-nuts/bd1c2b60-8459-46d8-a022-0527f0fba150n%40googlegroups.com?utm_medium=email_source=footer).

--
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/CAFiZK1w2mB6UDaKBELxA-yZn1MTmV8%3Dw-%2Bg5JhFiDgnjTn5b7w%40mail.gmail.com](https://groups.google.com/d/msgid/golang-nuts/CAFiZK1w2mB6UDaKBELxA-yZn1MTmV8%3Dw-%2Bg5JhFiDgnjTn5b7w%40mail.gmail.com?utm_medium=email_source=footer).

-- 
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/c-64693-kfekqpuu-5nan9y%3D1lzmhpo%402.gethop.com.


Re: [go-nuts] Cross compiling for linux from dawin

2020-09-22 Thread Mixo Ndleve
 FiloSottile/musl-cross/musl-cross is set up. (
https://subscription.packtpub.com/book/application_development/9781789138412/app02/app02lvl1sec98/cross-compiling-for-linux-with-cgo
)

With it we are able to cross compile for windows and linux from darwin, the
problem arises as soon as we import _ "github.com/cvigo/go_ibm_db"

On Tue, Sep 22, 2020 at 9:46 PM Marcin Romaszewicz 
wrote:

> Your compiler environment for C code is still building for Darwin, most
> likely. You need to set up a cross compiler and use cgo (
> https://golang.org/cmd/cgo/). $CC should invoke your cross compiler.
>
> On Tue, Sep 22, 2020 at 11:19 AM Mixo Ndleve  wrote:
>
>> Experiencing this problem when "github.com/cvigo/go_ibm_db" is imported
>>
>> ../../../go/pkg/mod/
>> github.com/lunny/godbc@v0.0.0-20131220142036-57f94ee1eb13/api/api.go:13:9:
>> undefined: SQLSMALLINT
>> ../../../go/pkg/mod/
>> github.com/lunny/godbc@v0.0.0-20131220142036-57f94ee1eb13/api/api.go:14:9:
>> undefined: SQLUSMALLINT
>> ../../../go/pkg/mod/
>> github.com/lunny/godbc@v0.0.0-20131220142036-57f94ee1eb13/api/api.go:15:9:
>> undefined: SQLUSMALLINT
>> ../../../go/pkg/mod/
>> github.com/lunny/godbc@v0.0.0-20131220142036-57f94ee1eb13/api/api.go:19:12:
>> undefined: SQLSMALLINT
>> ../../../go/pkg/mod/
>> github.com/lunny/godbc@v0.0.0-20131220142036-57f94ee1eb13/api/api.go:20:12:
>> undefined: SQLUSMALLINT
>> ../../../go/pkg/mod/
>> github.com/lunny/godbc@v0.0.0-20131220142036-57f94ee1eb13/api/api.go:21:12:
>> undefined: SQLUSMALLINT
>> ../../../go/pkg/mod/
>> github.com/lunny/godbc@v0.0.0-20131220142036-57f94ee1eb13/api/api.go:22:12:
>> undefined: SQLUSMALLINT
>> ../../../go/pkg/mod/
>> github.com/lunny/godbc@v0.0.0-20131220142036-57f94ee1eb13/api/api.go:23:12:
>> undefined: SQLUSMALLINT
>> ../../../go/pkg/mod/
>> github.com/lunny/godbc@v0.0.0-20131220142036-57f94ee1eb13/api/api.go:24:12:
>> undefined: SQLUSMALLINT
>> ../../../go/pkg/mod/
>> github.com/lunny/godbc@v0.0.0-20131220142036-57f94ee1eb13/api/api.go:25:12:
>> undefined: SQLUINTEGER
>> ../../../go/pkg/mod/
>> github.com/lunny/godbc@v0.0.0-20131220142036-57f94ee1eb13/api/api.go:25:12:
>> too many errors
>>
>> --
>> 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/bd1c2b60-8459-46d8-a022-0527f0fba150n%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/CAFiZK1w2mB6UDaKBELxA-yZn1MTmV8%3Dw-%2Bg5JhFiDgnjTn5b7w%40mail.gmail.com.


Re: [go-nuts] Windows Write Call Error when Writing to Network mapped Folder.

2020-09-22 Thread Ian Lance Taylor
On Tue, Sep 22, 2020 at 11:14 AM helhadad  wrote:
>
> Hi Folks,
> I am trying to create file and write to it on a network mapped drive, which I 
> can access, create, delete and edit files using windows explorer or CMD 
> (Windows 10/Server 2016).
>
> You can find all details of the issue and response from other Go-Expert below:
>
> https://stackoverflow.com/questions/63960049/writing-to-networked-mapped-drive-empty-files-or-failure
>
> I would appreciate if you enlighten me about the issue and how to solve it.

According to Stack Overflow you are getting errors that say "the
parameter is incorrect."  If I search for "Windows the parameter is
incorrect" all the top links are about reformatting the disk.  So
perhaps you should give that a try.

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


Re: [go-nuts] Cross compiling for linux from dawin

2020-09-22 Thread Marcin Romaszewicz
Your compiler environment for C code is still building for Darwin, most
likely. You need to set up a cross compiler and use cgo (
https://golang.org/cmd/cgo/). $CC should invoke your cross compiler.

On Tue, Sep 22, 2020 at 11:19 AM Mixo Ndleve  wrote:

> Experiencing this problem when "github.com/cvigo/go_ibm_db" is imported
>
> ../../../go/pkg/mod/
> github.com/lunny/godbc@v0.0.0-20131220142036-57f94ee1eb13/api/api.go:13:9:
> undefined: SQLSMALLINT
> ../../../go/pkg/mod/
> github.com/lunny/godbc@v0.0.0-20131220142036-57f94ee1eb13/api/api.go:14:9:
> undefined: SQLUSMALLINT
> ../../../go/pkg/mod/
> github.com/lunny/godbc@v0.0.0-20131220142036-57f94ee1eb13/api/api.go:15:9:
> undefined: SQLUSMALLINT
> ../../../go/pkg/mod/
> github.com/lunny/godbc@v0.0.0-20131220142036-57f94ee1eb13/api/api.go:19:12:
> undefined: SQLSMALLINT
> ../../../go/pkg/mod/
> github.com/lunny/godbc@v0.0.0-20131220142036-57f94ee1eb13/api/api.go:20:12:
> undefined: SQLUSMALLINT
> ../../../go/pkg/mod/
> github.com/lunny/godbc@v0.0.0-20131220142036-57f94ee1eb13/api/api.go:21:12:
> undefined: SQLUSMALLINT
> ../../../go/pkg/mod/
> github.com/lunny/godbc@v0.0.0-20131220142036-57f94ee1eb13/api/api.go:22:12:
> undefined: SQLUSMALLINT
> ../../../go/pkg/mod/
> github.com/lunny/godbc@v0.0.0-20131220142036-57f94ee1eb13/api/api.go:23:12:
> undefined: SQLUSMALLINT
> ../../../go/pkg/mod/
> github.com/lunny/godbc@v0.0.0-20131220142036-57f94ee1eb13/api/api.go:24:12:
> undefined: SQLUSMALLINT
> ../../../go/pkg/mod/
> github.com/lunny/godbc@v0.0.0-20131220142036-57f94ee1eb13/api/api.go:25:12:
> undefined: SQLUINTEGER
> ../../../go/pkg/mod/
> github.com/lunny/godbc@v0.0.0-20131220142036-57f94ee1eb13/api/api.go:25:12:
> too many errors
>
> --
> 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/bd1c2b60-8459-46d8-a022-0527f0fba150n%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%2Bv29Lv9V3n%2BKE4wxsUdz%2BoQ6U%2BNYm_KFtpaG_2PYrThBwDD0g%40mail.gmail.com.


[go-nuts] Cross compiling for linux from dawin

2020-09-22 Thread Mixo Ndleve
Experiencing this problem when "github.com/cvigo/go_ibm_db" is imported 

../../../go/pkg/mod/github.com/lunny/godbc@v0.0.0-20131220142036-57f94ee1eb13/api/api.go:13:9:
 
undefined: SQLSMALLINT
../../../go/pkg/mod/github.com/lunny/godbc@v0.0.0-20131220142036-57f94ee1eb13/api/api.go:14:9:
 
undefined: SQLUSMALLINT
../../../go/pkg/mod/github.com/lunny/godbc@v0.0.0-20131220142036-57f94ee1eb13/api/api.go:15:9:
 
undefined: SQLUSMALLINT
../../../go/pkg/mod/github.com/lunny/godbc@v0.0.0-20131220142036-57f94ee1eb13/api/api.go:19:12:
 
undefined: SQLSMALLINT
../../../go/pkg/mod/github.com/lunny/godbc@v0.0.0-20131220142036-57f94ee1eb13/api/api.go:20:12:
 
undefined: SQLUSMALLINT
../../../go/pkg/mod/github.com/lunny/godbc@v0.0.0-20131220142036-57f94ee1eb13/api/api.go:21:12:
 
undefined: SQLUSMALLINT
../../../go/pkg/mod/github.com/lunny/godbc@v0.0.0-20131220142036-57f94ee1eb13/api/api.go:22:12:
 
undefined: SQLUSMALLINT
../../../go/pkg/mod/github.com/lunny/godbc@v0.0.0-20131220142036-57f94ee1eb13/api/api.go:23:12:
 
undefined: SQLUSMALLINT
../../../go/pkg/mod/github.com/lunny/godbc@v0.0.0-20131220142036-57f94ee1eb13/api/api.go:24:12:
 
undefined: SQLUSMALLINT
../../../go/pkg/mod/github.com/lunny/godbc@v0.0.0-20131220142036-57f94ee1eb13/api/api.go:25:12:
 
undefined: SQLUINTEGER
../../../go/pkg/mod/github.com/lunny/godbc@v0.0.0-20131220142036-57f94ee1eb13/api/api.go:25:12:
 
too many errors

-- 
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/bd1c2b60-8459-46d8-a022-0527f0fba150n%40googlegroups.com.


[go-nuts] Windows Write Call Error when Writing to Network mapped Folder.

2020-09-22 Thread helhadad
Hi Folks,
I am trying to create file and write to it on a *network mapped drive*, 
which I can access, create, delete and edit files using windows explorer or 
CMD (Windows 10/Server 2016).  

You can find all details of the issue and response from other Go-Expert 
below:

https://stackoverflow.com/questions/63960049/writing-to-networked-mapped-drive-empty-files-or-failure

I would appreciate if you enlighten me about the issue and how to solve it.

Regards,
helhadad.

-- 
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/5e27422c-9e8b-4ee9-a511-49face6dfafdn%40googlegroups.com.


Re: [go-nuts] Find n-th root of a big number

2020-09-22 Thread roger peppe
Relevant issue: https://golang.org/issue/14102


On Tue, 22 Sep 2020 at 08:54, Nasir Hussain 
wrote:

> The Amazing Rob Pike :D
>
> On Tue, Sep 22, 2020 at 12:13 PM Rob Pike  wrote:
>
>> I'm not going to debug you program for you - you'll learn more doing it
>> yourself, but I glanced at it and saw immediately that you're missing an
>> easy optimization. Raising a number to an integer power can be done much
>> faster by repeated squaring according to the bit pattern of the exponent.
>> I'll leave that cryptic comment alone to let you puzzle it out yourself.
>> (Don't look it up; it's much more fun to figure out.)
>>
>> -rob
>>
>>
>> On Tue, Sep 22, 2020 at 3:11 AM Hau Phan  wrote:
>>
>>> i can't find get n-th root in document of go big package so i decided to
>>> do it myself using newton's method. i found a solution at
>>> https://www.geeksforgeeks.org/n-th-root-number/ and start to implement
>>> in go. but my code only work fine for base 2. other base result gone too
>>> far from correct.
>>>
>>> Anyone could show me where am i wrong.
>>>
>>> Here's my code
>>>
>>> ```go
>>> package main
>>>
>>> import (
>>> "fmt"
>>> "math/big"
>>> "math/rand"
>>> )
>>>
>>> // PowFloat return x^n
>>> func PowFloat(x *big.Float, n int64) *big.Float {
>>> result := new(big.Float).SetInt64(1)
>>> for i := 0; i < int(n); i++ {
>>> result.Mul(result, x)
>>> }
>>> return result
>>> }
>>>
>>> // GetNthRoothFloat get nth root of a using newton's method
>>> func GetNthRoothFloat(a *big.Float, n int64) *big.Float {
>>> N := new(big.Float).SetInt64(n)
>>> xPre := new(big.Float).SetInt64(int64(rand.Intn(10) + 1))
>>> eps := new(big.Float).SetFloat64(0.001)
>>> delX := new(big.Float).SetInt64(2147483647)
>>> xK := new(big.Float).SetInt64(0)
>>>
>>> for delX.Cmp(eps) > 0 {
>>> t1 := new(big.Float).Sub(N, new(big.Float).SetFloat64(1.0)) // t1 = n-1
>>> t1 = t1.Mul(t1, xPre)   // t1 =
>>> (N-1) * xPre
>>> t2 := new(big.Float).Quo(a, PowFloat(xPre, n-1))// t2 = a/(
>>> xPre^(n-1) )
>>> t3 := new(big.Float).Add(t1, t2)// t3 = t1 +
>>> t2
>>> xK.Quo(t3, N)
>>> delX = new(big.Float).Sub(xK, xPre)
>>> delX.Abs(delX)
>>> xPre = xK.Copy(xK)
>>> }
>>> return xK
>>> }
>>>
>>> func main() {
>>> t := new(big.Float).SetInt64(64)
>>> fmt.Println(GetNthRoothFloat(t, 3))
>>> }
>>> ```
>>>
>>> --
>>> 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/5a38a7fe-426b-4f94-905e-79b42dcaa611n%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/CAOXNBZQrjBjT-dDEK1Atu7R32aT1mgTsSAYhXAF7hXmj35BjuQ%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/CAG9C_MeG0P%3DSy5732WvW-EfsreSObQve%3DLsEUms%3DdWdRenvZ4Q%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/CAJhgachbaTaxkWv66ktuPz1RPSnAm7zgc1r0kqEb2T4hUWEt3A%40mail.gmail.com.


Re: [go-nuts] mytex.RWLock recursive read lock

2020-09-22 Thread 'Bryan C. Mills' via golang-nuts
Note that a lock on a sync.Mutex or sync.RWMutex is *not* held by a 
specific goroutine: it can be locked by one goroutine, then communicated by 
some other means (such as being sent on a channel) and unlocked on a 
*different* goroutine. (See also https://golang.org/issue/9201.)

That is: these locks *cannot* be reentrant because they do not contain 
goroutine-specific metadata.

I read through the docs for this type again, and noticed that while the 
documentation for the Unlock method seems very clear on this point, the 
documentation for the type itself is not. (I 
filed https://golang.org/issue/41555, for which you are welcome to 
contribute  a fix!)

On Monday, September 21, 2020 at 8:26:46 AM UTC-4 axel.wa...@googlemail.com 
wrote:

> FTR, I still don't think the docs *are* ambiguous. The authoritative part 
> is
>
> If a goroutine holds a RWMutex for reading and another goroutine might 
>> call Lock, no goroutine should expect to be able to acquire a read lock 
>> until the initial read lock is released.
>
>
> The rest is just additional explanation. This sentence alone is already 
> sufficient to define the behavior.
>
> On Mon, Sep 21, 2020 at 2:14 PM Axel Wagner  
> wrote:
>
>> On Mon, Sep 21, 2020 at 2:06 PM Henrik Johansson  
>> wrote:
>>
>>> Ambiguous docs however aren't generally good in any way. This came up as 
>>> a consequence of real code being changed by a new very skilled developer 
>>> and there was quite a bit discussion that could have been avoided with 
>>> clearer docs.
>>>
>>
>> I think it would be useful to be more explicit about the use-case then. 
>> As I said, I can't really fathom a situation where you'd *want* to do that 
>> and if you don't want it, I can't imagine how it would matter whether you 
>> can.
>>  
>>
>>>
>>> We have sorted the issue I mostly wanted to confirm my suspicion wrt 
>>> nested read locks.
>>>
>>> On Mon, 21 Sep 2020, 13:31 Axel Wagner,  
>>> wrote:
>>>
 To elaborate a bit: You are correct in that there is a slight syntactic 
 ambiguity whether "this prohibits" refers to the entire sentence ("if 
 another goroutine might call Lock, then a second RLock might not be 
 acquired"), or only to the second half. I would argue the rest of the 
 section makes it clear that the second version is intended - "a goroutine 
 can not expect a second RLock to be acquired. This prohibits…".

 But yes, it certainly can be argued that the ambiguity hides the 
 possibility of nested RLocks when no other goroutine calls Lock. But even 
 if then: Given that this would not be useful (an RLock without a 
 concurrent 
 Lock is functionally a no-op, AIUI), but *can* lead to incorrect code if 
 applied improperly, that possibility doesn't seem worthwhile to advertise 
 further.

 So even if the docs are ambiguous, that hardly seems a problem.

 On Mon, Sep 21, 2020 at 12:58 PM Axel Wagner  
 wrote:

> It only says that's excluded *if* you can have a concurrent Lock call.
>
> On Mon, Sep 21, 2020 at 12:48 PM Henrik Johansson  
> wrote:
>
>> Yes that's the canonical deadlock but doesn't the docs say
>>  
>> "In particular, this prohibits recursive read locking" 
>>
>> which it doesn't unless you mix reads and writes.
>>
>> I get that it's not advisable but it's not prohibited either or there 
>> would be a panic or something.
>>
>> On Mon, 21 Sep 2020, 12:30 Axel Wagner,  
>> wrote:
>>
>>> (Note, FWIW, that in particular no write locks need to be *held*. 
>>> It's enough for Lock to be *called*, it doesn't have to have returned 
>>> yet)
>>>
>>> On Mon, Sep 21, 2020 at 12:29 PM Axel Wagner <
>>> axel.wa...@googlemail.com> wrote:
>>>
 I feel like the docs are pretty precise in what they say and why.

 a blocked Lock call excludes new readers from acquiring the lock.


 This means, the following could happen:
 Goroutine 1 calls RLock, acquires a Read-Lock
 Goroutine 2 calls Lock, blocking
 Goroutine 1 calls RLock again, blocking (as no new read locks can 
 be acquired while GR 2 is blocked).
 Thus, you get a deadlock.

 It also has a conditional on the section

 If a goroutine holds a RWMutex for reading and another goroutine 
> might call Lock […]

  
 So if you know that no other goroutine might call Lock 
 concurrently, then yes, you can call RLock twice. I can't really 
 imagine a 
 setting where you'd need an RWMutex and have that assurance and need 
 recursive read locks. But there might be one.

 On Mon, Sep 21, 2020 at 12:16 PM Henrik Johansson <
 dahan...@gmail.com> wrote:

>
> https://golang.org/pkg/sync/#RWMutex
>

Re: [go-nuts] how to use replace directives in go.mod in dev but not prod

2020-09-22 Thread Paul Jolly
> CI probably is the anwser, made a utility based on golang.org/x/mod which 
> parses go.mod and checks if replaces are there and exit with error state if 
> they are.

This isn't the problem discussed in 26640 at least. There, the issue
is that it is not currently possible to have a go.mod.local file
_outside_ of source control that augments the real go.mod.

Your suggestion is covered by the gorelease tool
(https://pkg.go.dev/golang.org/x/exp/cmd/gorelease)

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


Re: [go-nuts] how to use replace directives in go.mod in dev but not prod

2020-09-22 Thread Denis Cheremisov
CI probably is the anwser, made a utility based on golang.org/x/mod which 
parses go.mod and checks if replaces are there and exit with error state if 
they are.

вторник, 22 сентября 2020 г. в 11:21:55 UTC+3, Paul Jolly: 

> 26640 is an open issue describing the same problem you're describing. 
> Unfortunately because it remains open there is not yet a solution.
>
>
> On Tue, 22 Sep 2020, 07:36 Alex Mills,  wrote:
>
>> i dont understand, is there a solution or just a proposal?
>>
>> On Mon, Sep 21, 2020, 23:03 Paul Jolly  wrote:
>>
>>> I just replied. I think that https://github.com/golang/go/issues/26640
>>> covers this.
>>>
>>> On Tue, 22 Sep 2020 at 06:52, Alex Mills  wrote:
>>> >
>>> > I put this question on the golang issue tracker on github:
>>> > https://github.com/golang/go/issues/41546
>>> >
>>> > I am sure it's been answered before but hard to search for..anyone 
>>> know what the right approach is? I like how node.js / NPM solve it using 
>>> symlinks personally.
>>> >
>>> > --
>>> > 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...@googlegroups.com.
>>> > To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/golang-nuts/92794ec1-ee89-4c98-820e-750b1db079ffn%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/8a09fad1-005d-44f7-a0bd-7092edf2d643n%40googlegroups.com.


Re: [go-nuts] how to use replace directives in go.mod in dev but not prod

2020-09-22 Thread Paul Jolly
26640 is an open issue describing the same problem you're describing.
Unfortunately because it remains open there is not yet a solution.

On Tue, 22 Sep 2020, 07:36 Alex Mills,  wrote:

> i dont understand, is there a solution or just a proposal?
>
> On Mon, Sep 21, 2020, 23:03 Paul Jolly  wrote:
>
>> I just replied. I think that https://github.com/golang/go/issues/26640
>> covers this.
>>
>> On Tue, 22 Sep 2020 at 06:52, Alex Mills  wrote:
>> >
>> > I put this question on the golang issue tracker on github:
>> > https://github.com/golang/go/issues/41546
>> >
>> > I am sure it's been answered before but hard to search for..anyone know
>> what the right approach is? I like how node.js / NPM solve it using
>> symlinks personally.
>> >
>> > --
>> > 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/92794ec1-ee89-4c98-820e-750b1db079ffn%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/CACoUkn7BybiwHDdP48TH462AYhAEupMF_rAXxHHy8p%2BPW%3DsGqw%40mail.gmail.com.


Re: [go-nuts] Find n-th root of a big number

2020-09-22 Thread Nasir Hussain
The Amazing Rob Pike :D

On Tue, Sep 22, 2020 at 12:13 PM Rob Pike  wrote:

> I'm not going to debug you program for you - you'll learn more doing it
> yourself, but I glanced at it and saw immediately that you're missing an
> easy optimization. Raising a number to an integer power can be done much
> faster by repeated squaring according to the bit pattern of the exponent.
> I'll leave that cryptic comment alone to let you puzzle it out yourself.
> (Don't look it up; it's much more fun to figure out.)
>
> -rob
>
>
> On Tue, Sep 22, 2020 at 3:11 AM Hau Phan  wrote:
>
>> i can't find get n-th root in document of go big package so i decided to
>> do it myself using newton's method. i found a solution at
>> https://www.geeksforgeeks.org/n-th-root-number/ and start to implement
>> in go. but my code only work fine for base 2. other base result gone too
>> far from correct.
>>
>> Anyone could show me where am i wrong.
>>
>> Here's my code
>>
>> ```go
>> package main
>>
>> import (
>> "fmt"
>> "math/big"
>> "math/rand"
>> )
>>
>> // PowFloat return x^n
>> func PowFloat(x *big.Float, n int64) *big.Float {
>> result := new(big.Float).SetInt64(1)
>> for i := 0; i < int(n); i++ {
>> result.Mul(result, x)
>> }
>> return result
>> }
>>
>> // GetNthRoothFloat get nth root of a using newton's method
>> func GetNthRoothFloat(a *big.Float, n int64) *big.Float {
>> N := new(big.Float).SetInt64(n)
>> xPre := new(big.Float).SetInt64(int64(rand.Intn(10) + 1))
>> eps := new(big.Float).SetFloat64(0.001)
>> delX := new(big.Float).SetInt64(2147483647)
>> xK := new(big.Float).SetInt64(0)
>>
>> for delX.Cmp(eps) > 0 {
>> t1 := new(big.Float).Sub(N, new(big.Float).SetFloat64(1.0)) // t1 = n-1
>> t1 = t1.Mul(t1, xPre)   // t1 = (N-1)
>> * xPre
>> t2 := new(big.Float).Quo(a, PowFloat(xPre, n-1))// t2 = a/(
>> xPre^(n-1) )
>> t3 := new(big.Float).Add(t1, t2)// t3 = t1 +
>> t2
>> xK.Quo(t3, N)
>> delX = new(big.Float).Sub(xK, xPre)
>> delX.Abs(delX)
>> xPre = xK.Copy(xK)
>> }
>> return xK
>> }
>>
>> func main() {
>> t := new(big.Float).SetInt64(64)
>> fmt.Println(GetNthRoothFloat(t, 3))
>> }
>> ```
>>
>> --
>> 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/5a38a7fe-426b-4f94-905e-79b42dcaa611n%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/CAOXNBZQrjBjT-dDEK1Atu7R32aT1mgTsSAYhXAF7hXmj35BjuQ%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/CAG9C_MeG0P%3DSy5732WvW-EfsreSObQve%3DLsEUms%3DdWdRenvZ4Q%40mail.gmail.com.


Re: [go-nuts] Find n-th root of a big number

2020-09-22 Thread Rob Pike
I'm not going to debug you program for you - you'll learn more doing it
yourself, but I glanced at it and saw immediately that you're missing an
easy optimization. Raising a number to an integer power can be done much
faster by repeated squaring according to the bit pattern of the exponent.
I'll leave that cryptic comment alone to let you puzzle it out yourself.
(Don't look it up; it's much more fun to figure out.)

-rob


On Tue, Sep 22, 2020 at 3:11 AM Hau Phan  wrote:

> i can't find get n-th root in document of go big package so i decided to
> do it myself using newton's method. i found a solution at
> https://www.geeksforgeeks.org/n-th-root-number/ and start to implement in
> go. but my code only work fine for base 2. other base result gone too far
> from correct.
>
> Anyone could show me where am i wrong.
>
> Here's my code
>
> ```go
> package main
>
> import (
> "fmt"
> "math/big"
> "math/rand"
> )
>
> // PowFloat return x^n
> func PowFloat(x *big.Float, n int64) *big.Float {
> result := new(big.Float).SetInt64(1)
> for i := 0; i < int(n); i++ {
> result.Mul(result, x)
> }
> return result
> }
>
> // GetNthRoothFloat get nth root of a using newton's method
> func GetNthRoothFloat(a *big.Float, n int64) *big.Float {
> N := new(big.Float).SetInt64(n)
> xPre := new(big.Float).SetInt64(int64(rand.Intn(10) + 1))
> eps := new(big.Float).SetFloat64(0.001)
> delX := new(big.Float).SetInt64(2147483647)
> xK := new(big.Float).SetInt64(0)
>
> for delX.Cmp(eps) > 0 {
> t1 := new(big.Float).Sub(N, new(big.Float).SetFloat64(1.0)) // t1 = n-1
> t1 = t1.Mul(t1, xPre)   // t1 = (N-1)
> * xPre
> t2 := new(big.Float).Quo(a, PowFloat(xPre, n-1))// t2 = a/(
> xPre^(n-1) )
> t3 := new(big.Float).Add(t1, t2)// t3 = t1 + t2
> xK.Quo(t3, N)
> delX = new(big.Float).Sub(xK, xPre)
> delX.Abs(delX)
> xPre = xK.Copy(xK)
> }
> return xK
> }
>
> func main() {
> t := new(big.Float).SetInt64(64)
> fmt.Println(GetNthRoothFloat(t, 3))
> }
> ```
>
> --
> 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/5a38a7fe-426b-4f94-905e-79b42dcaa611n%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/CAOXNBZQrjBjT-dDEK1Atu7R32aT1mgTsSAYhXAF7hXmj35BjuQ%40mail.gmail.com.


Re: [go-nuts] how to use replace directives in go.mod in dev but not prod

2020-09-22 Thread Alex Mills
i dont understand, is there a solution or just a proposal?

On Mon, Sep 21, 2020, 23:03 Paul Jolly  wrote:

> I just replied. I think that https://github.com/golang/go/issues/26640
> covers this.
>
> On Tue, 22 Sep 2020 at 06:52, Alex Mills  wrote:
> >
> > I put this question on the golang issue tracker on github:
> > https://github.com/golang/go/issues/41546
> >
> > I am sure it's been answered before but hard to search for..anyone know
> what the right approach is? I like how node.js / NPM solve it using
> symlinks personally.
> >
> > --
> > 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/92794ec1-ee89-4c98-820e-750b1db079ffn%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/CAL6oN2cws5H-N5k_KuDk_QiyHg%3DKV523t%3D0hHWHCHmqK%2Bub0MQ%40mail.gmail.com.


Re: [go-nuts] Better dependency management in go

2020-09-22 Thread 'Axel Wagner' via golang-nuts
Hi,

On Tue, Sep 22, 2020 at 12:01 AM Shirshendu Bhowmick <
shirshendu.bhowmi...@gmail.com> wrote:

> There are some confusing syntax, for example
> github.com/myorganzation/mypackage/pkg
> This url results in 404 in browsers but somehow go resolves it, so it
> seems like depending on hosting providers such as GitHub, BitBucket etc go
> have different mechanisms of resolving the URL.
> Which is somewhat described in here
> 


I understand that there is lots of third-party material out there calling
import-paths "URLs", but they aren't. For one, they don't have a scheme. I
know that this kind of proves your point, that the situation might be
confusing for beginners, but it's an important distinction, IMO,
specifically to avoid this kind of problem.


>-
>
>Though i am not sure about this but i didn't find any way by which i
>can tell that this indirect dependency x is from the dependency y, just by
>looking into go.sum or go.mod files.
>
> `go mod why` can tell you. I don't feel this is a reasonable expectation
to make it visible in the dependency files itself. It would require every
module to ship a graph-representation of its dependency graph, for the sole
benefit of not having to invoke the go tool - and even then, you'll
probably still want to do that, so you don't have to mentally walk the
graph yourself.

>
>-
>
>Error messages not being so helpful
>If i try to go get a package in a directory which is not a module i
>get an error message which is not so helpful for beginners
>
> go get github.com/gofiber/fiber/v2 cannot find package "
> github.com/gofiber/fiber/v2" in any of: /usr/local/go/src/
> github.com/gofiber/fiber/v2 (from $GOROOT)
> /Users/shirshendubhowmick/go/src/github.com/gofiber/fiber/v2 (from
> $GOPATH)
>

I think this particular example might get simpler in the future, when
GO111MODULE=on becomes the default, because the go tool won't look for
dependencies in GOPATH. In general, I don't think error messages can be
improved holistically - changing the approach will just lead to new,
confusing error messages. I think error messages specifically are an area
where you *have* to look at specific examples and fix them one by one.

Now our dependency file (currently go.mod) will have a mapping of module
> name and its URL to create an alias for the module, for example

mypackage git+ssh://g...@github.com/myorganization/mypackage


 At the end of the day, the Go compiler requires unambiguous unique package
names. How would you address the case where you and a dependency of yours
would choose the same alias for different packages or different aliases for
the same package? If an alias has to be changed to resolve such a conflict,
how do you edit the code of your dependency to reflect that? Wouldn't you,
in the end, need to manually maintain a list of all your transitive
dependencies to give names to things?

That's the primary reason for putting a domain-name into the import-path.
It allows you to piggyback on an existing system to assign unambiguous
names to things. It is pretty central to having no centralized package
repository - usually, this central repository provides the uniqueness
required by the language. We have to replace it with something. Putting a
domain-name in there is a simple solution that *also* has the side-effect
of allowing us to layer automatic package discovery on top of it.


>-
>
>Everywhere in the code base a consumer will use the alias name instead
>of a URL to import the package, for example
>
>import "mypackage"
>
>Now how do we know where the module is located inside the repo ? Right
>now we add a go.mod file in every module root directory. With this change
>maybe we can add a single file in the repo root which will tell where the
>modules are located relative to the repo root. I guess this will give more
>flexibility to both the module developer and consumer.
>
>For updating version, we can either do it manually by changing the URL
>or maybe via some tool like go update mypackage
>-
>
>*Problem 2:* Improving the error messages
>This might be a simpler problem to solve compared to the above one.
>There is no specific solution to this. I think the best way is to run an
>audit to figure out point of failures while working with modules in go. And
>try to have as much meaningful error message as possible with some detailed
>log.
>
> This is very high level solution proposal, happy to discuss more on it and
> also pros & cons, gotchas, bottlenecks etc.
>
> Original github issue link:
> https://github.com/golang/go/issues/41510
>
> --
> 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
> 

Re: [go-nuts] how to use replace directives in go.mod in dev but not prod

2020-09-22 Thread Paul Jolly
I just replied. I think that https://github.com/golang/go/issues/26640
covers this.

On Tue, 22 Sep 2020 at 06:52, Alex Mills  wrote:
>
> I put this question on the golang issue tracker on github:
> https://github.com/golang/go/issues/41546
>
> I am sure it's been answered before but hard to search for..anyone know what 
> the right approach is? I like how node.js / NPM solve it using symlinks 
> personally.
>
> --
> 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/92794ec1-ee89-4c98-820e-750b1db079ffn%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/CACoUkn7xmOmN16bi8dyfeUdnzcHXZbRUweWeX%2B1x70-bsyoAQg%40mail.gmail.com.