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&utm_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&utm_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.