Re: [go-nuts] Change in virtual memory patterns in Go 1.12

2019-04-15 Thread Rémy Oudompheng
Thanks Austin, The application workload is a kind of fragmentation torture test as it involves a mixture of many long-lived small and large (>100 MB) objects, with regularly allocated short-lived small and large objects. I have tried creating a sample synthetic reproducer but did not succeed at

[go-nuts] Re: [go-cloud] What is recommended way to initialize and keep prepared statements in go Lang

2019-04-15 Thread 'Ross Light' via golang-nuts
(+cc golang-nuts, +bcc go-cloud) go-cloud is for the discussion of the Go CDK . This sounds like a more general Go question, so redirecting you over to golang-nuts. -Ross On Mon, Apr 15, 2019 at 12:52 PM Shrinath agarwal wrote: > Hi Team ,I am new in Go lang .I am trying

Re: [go-nuts] SHA256 with input not aligned to x8 bit

2019-04-15 Thread Paolo C.
Thanks Rog for the answer. But that won't work. SHA-256 is a standard (FIPS180-4) and if one uses it, is for interoperate in most cases. It may happen that you need only to hash 8bit bounded streams, but it also may not be the case. So, any implementation should be careful of being correct. You

Re: [go-nuts] What is recommended way to initialize and keep prepared statements in go Lang

2019-04-15 Thread eric via golang-nuts
On Sunday, April 14, 2019 at 3:17:46 AM UTC-7, Shrinath agarwal wrote: > > Hi Marcin, > > I know about Prepare function supported by sql package .My initial > question was what is better way to pass multiple prepare statements on > different http handlers . > ex: we can construct struct like

Re: [go-nuts] floating point question

2019-04-15 Thread Kurtis Rader
On Mon, Apr 15, 2019 at 2:19 AM Miki Tebeka wrote: > Can anyone explain the below? > (When printing out b with %.20f it prints 1.20996447) > > package main > > import "fmt" > > func main() { > a, b := 1.1*1.1, 1.21 > fmt.Println(a == b) // true > fmt.Println(1.1*1.1 == 1.21)

[go-nuts] Re: Language Specification nit under Constant declarations

2019-04-15 Thread Ian Lance Taylor
[ +gri ] On Mon, Apr 15, 2019 at 9:27 AM Marvin Renich wrote: > > At https://golang.org/ref/spec#Constant_declarations where it talks > about omitting the expression list, it says > > Such an empty list is equivalent to the textual substitution of the > first preceding non-empty expression

Re: [go-nuts] floating point question

2019-04-15 Thread David Riley
On Apr 15, 2019, at 12:47 PM, Miki Tebeka wrote: > > On Monday, April 15, 2019 at 2:12:18 PM UTC+3, Jan Mercl wrote: > > 1.1*1.1 and 1.21 are untyped constants and have much higher precision at > which they are not equal. > Does that mean that the Go compiler is using floats with more

Re: [go-nuts] floating point question

2019-04-15 Thread Jan Mercl
On Mon, Apr 15, 2019 at 6:47 PM Miki Tebeka wrote: > Does that mean that the Go compiler is using floats with more precision than the runtime? Absolutely: https://golang.org/ref/spec#Constants Represent integer constants with at least 256 bits. Represent floating-point constants,

Re: [go-nuts] Casting across types

2019-04-15 Thread 'simon place' via golang-nuts
may be missing the point, but why go thought an interface{}? https://play.golang.org/p/Ol7e6UrNAWq -- 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

Re: [go-nuts] floating point question

2019-04-15 Thread Miki Tebeka
On Monday, April 15, 2019 at 2:12:18 PM UTC+3, Jan Mercl wrote: 1.1*1.1 and 1.21 are untyped constants and have much higher precision at > which they are not equal. > Does that mean that the Go compiler is using floats with more precision than the runtime? -- You received this message

[go-nuts] Language Specification nit under Constant declarations

2019-04-15 Thread Marvin Renich
At https://golang.org/ref/spec#Constant_declarations where it talks about omitting the expression list, it says Such an empty list is equivalent to the textual substitution of the first preceding non-empty expression list and its type if any. In the declaration const ( One = iota

Re: [go-nuts] The go way to compare values against an enum

2019-04-15 Thread Sankar P
Whoa. I did not realise this. Thanks for the help. திங்., 15 ஏப்., 2019, பிற்பகல் 9:54 அன்று, Marvin Renich எழுதியது: > Roger and Jan have given you good answers, but I would like to comment > on another aspect of your code. > > * Sankar [190415 04:53]: > > type weekday string > > > > const (

Re: [go-nuts] The go way to compare values against an enum

2019-04-15 Thread Marvin Renich
Roger and Jan have given you good answers, but I would like to comment on another aspect of your code. * Sankar [190415 04:53]: > type weekday string > > const ( > Monday weekday = "Monday" > Tuesday = "Tuesday" > . > . > . > ) Note that the type of Monday will be weekday, while the

[go-nuts] Re: Inject Mock Instead of Actual Implementation in Tests, Using "wire"

2019-04-15 Thread Kaveh Shahbazian
It is inside the documentation of wire - I should read it more carefully: here . On Saturday, April 13, 2019 at 6:25:12 PM UTC+2, Kaveh Shahbazian wrote: > > BTW I am aware that some build tag tricks can be used to

Re: [go-nuts] Concurrency safe struct access

2019-04-15 Thread michael . f . ellis
FWIW, here's the pattern I've settled on for my actual application. https://play.golang.org/p/OBVsp-Rjknf It uses sync.Mutex only and includes the mutex as a member of the guardedState struct. The deciding factor was that my industrial control application has a very large state struct with

Re: [go-nuts] Casting across types

2019-04-15 Thread Sankar P
Thanks :) திங்., 15 ஏப்., 2019, பிற்பகல் 4:20 அன்று, roger peppe எழுதியது: > The dynamic type conversion needs to specify the exact type that was put > into the interface (B in this case). > You can convert it back to A afterwards: > https://play.golang.org/p/jBRtR_8RloC > > On Mon, 15 Apr 2019

Re: [go-nuts] floating point question

2019-04-15 Thread Jan Mercl
On Mon, Apr 15, 2019 at 11:19 AM Miki Tebeka wrote: > Can anyone explain the below? a and b have 64b precision and they are assigned the same value, after that value is rounded to the lower precision. 1.1*1.1 and 1.21 are untyped constants and have much higher precision at which they are not

Re: [go-nuts] Casting across types

2019-04-15 Thread roger peppe
The dynamic type conversion needs to specify the exact type that was put into the interface (B in this case). You can convert it back to A afterwards: https://play.golang.org/p/jBRtR_8RloC On Mon, 15 Apr 2019 at 11:32, Sankar P wrote: > Playground url: https://play.golang.org/p/tDT7xCJJ_XN > >

Re: [go-nuts] Casting across types

2019-04-15 Thread Sankar P
Playground url: https://play.golang.org/p/tDT7xCJJ_XN திங்., 15 ஏப்., 2019, பிற்பகல் 4:01 அன்று, Sankar < sankar.curios...@gmail.com> எழுதியது: > I have the following go code: > > ``` > type A map[string]interface{} > type B map[string]interface{} > > func f(a A) { > fmt.Println(a) > } > > func

[go-nuts] Casting across types

2019-04-15 Thread Sankar
I have the following go code: ``` type A map[string]interface{} type B map[string]interface{} func f(a A) { fmt.Println(a) } func main() { var b B b = make(map[string]interface{}) i := interface{}(b) f(i.(A)) } ``` This code panics when I try to convert the B instance to type A. What is the

Re: [go-nuts] The go way to compare values against an enum

2019-04-15 Thread Sankar P
thanks guys. திங்., 15 ஏப்., 2019, பிற்பகல் 2:30 அன்று, roger peppe எழுதியது: > Go doesn't have enum types. For any given type, even if there are > constants of that type, that doesn't mean that those are all the valid > values of that type. For that reason, Go doesn't provide any specific >

Re: [go-nuts] SHA256 with input not aligned to x8 bit

2019-04-15 Thread roger peppe
The answer depends on what why you want to do this. If you don't need to interoperate with some other party that needs to arrive at the same checksum, you could write your own wrapper around sha256 that adds the necessary information to specify how many bits are significant. Something like this,

[go-nuts] floating point question

2019-04-15 Thread Miki Tebeka
Hi, Can anyone explain the below? (When printing out b with %.20f it prints 1.20996447) Thanks package main import "fmt" func main() { a, b := 1.1*1.1, 1.21 fmt.Println(a == b) // true fmt.Println(1.1*1.1 == 1.21) // false } -- You received this message because you

Re: [go-nuts] The go way to compare values against an enum

2019-04-15 Thread Jan Mercl
On Mon, Apr 15, 2019 at 10:53 AM Sankar wrote: > I want to evaluate if the string variable `day` is one of the valid permitted values for the [Ww]eekday custom type. What is the recommended / right go way of doing this ? Go has no enums and type weekday has no permitted/not permitted values.

Re: [go-nuts] The go way to compare values against an enum

2019-04-15 Thread roger peppe
Go doesn't have enum types. For any given type, even if there are constants of that type, that doesn't mean that those are all the valid values of that type. For that reason, Go doesn't provide any specific functionality to do what you'd like. I'd suggest creating a map that holds all the valid

Re: [go-nuts] Compile C++ with cgo

2019-04-15 Thread Sebastien Binet
On Thu, Apr 11, 2019 at 5:54 PM av wrote: > Hi *, > > I want to compile C++ code, because the library I need is C++ only. > > Here is my wrapper.hpp: > #include > > void print() { > std::cout << "Xx"; > } > > And here is my main.go: > package main > > // #cgo CXXFLAGS: -I. > // #cgo CFLAGS: