Re: [go-nuts] Should the program print true or false?

2020-09-17 Thread Marvin Renich
* 'Axel Wagner' via golang-nuts [200917 12:05]: > I think you might've intended this, which does indeed print true: > type S []S > var a, b S > a, b = S{0: b}, S{0: a} > fmt.Println(reflect.DeepEqual(a, b)) I was guessing he meant: type S []S var a, b S a = S{0: b} b = S{0: a}

Re: [go-nuts] Re: While implement ssh client using golang, record keyboard input

2020-09-15 Thread Marvin Renich
* sc3983...@gmail.com [200915 11:41]: > Hi Everyone: > > I have the same problem, How do I get user input command, with *SSH > client with a Interactive Shell* > > 在 2018年10月23日星期二 UTC+8上午4:57:50,Sun Frank写道: > > > > Hi Everyone: > > > > I came across a problem which puzzled me for

Re: [go-nuts] Definition of Method sets

2020-09-04 Thread Marvin Renich
* Yuu LongXue [200904 05:31]: > Hi all, > > I’m confused by the "method set" defined in go > specification,any one can help explain? > > The Go Programming Language Specification says that : > ``` > The method set of any other type T consists of all methods >

Re: [go-nuts] Re: How to know if interface{} data is nil w/o reflecting?

2020-08-27 Thread Marvin Renich
* targe...@gmail.com [200827 05:40]: > On Thursday, August 27, 2020 at 12:20:59 PM UTC+3 axel.wa...@googlemail.com > wrote: >> I'm saying the current situation is less confusing than what you >> describe, yes. >> >> AIUI, with what you describe, if I have a variable `x` of type `*T` >> and an

Re: [go-nuts] Re: module confusion

2020-08-15 Thread Marvin Renich
* fge...@gmail.com [200815 03:44]: > On 8/15/20, Marvin Renich wrote: > > * Volker Dobler [200814 14:53]: > >> On Friday, 14 August 2020 20:39:37 UTC+2, K Richard Pixley wrote: > >> > Isn't this the default location? I just untarred the distribution... > &g

Re: [go-nuts] Re: module confusion

2020-08-14 Thread Marvin Renich
* Volker Dobler [200814 14:53]: > On Friday, 14 August 2020 20:39:37 UTC+2, K Richard Pixley wrote: > > Isn't this the default location? I just untarred the distribution... > > No. There is a reason https://golang.org/doc/install#install > states to do tar -C /usr/local -xzf

Re: [go-nuts] my package not include in go modules

2020-07-29 Thread Marvin Renich
* Ali Hassan [200725 01:04]: > I want to import libraries in module file but modules add all other > libraries except those packages which I had created, DB is one of them. How > to import? > Error , please help me > to resolve Also note

Re: [go-nuts] Expanding variables and fmt.Printf() issue

2020-06-29 Thread Marvin Renich
[pedantic correction] * Marvin Renich [200629 14:10]: > The final argument to Printf is []interface{}, while you are trying to ^ ...interface{} ...Marvin -- You received this message because you are subscribed to the Goo

Re: [go-nuts] Expanding variables and fmt.Printf() issue

2020-06-29 Thread Marvin Renich
* yves baumes [200629 03:22]: > Hello, > > considering this code > > ``` > package main > > import ( > "fmt" > ) > > func main() { > host := []string{"127", "0", "0", "1"} > > fmt.Printf("%v.%v.%v.%v\n", host[0], host[1], host[2], host[3]) > fmt.Printf("%v.%v.%v.%v\n", host[0:4]...) > } >

Re: [go-nuts] Re: accessibility of module version information in executable

2020-06-26 Thread Marvin Renich
* seank...@gmail.com [200626 12:31]: > go version -m $binary > > runtime/debug.BuildInfo Thanks much! I looked through runtime, but did not think to look at runtime/debug. I was completely unaware of the -m option to go version. ...Marvin -- You received this message because you are

[go-nuts] accessibility of module version information in executable

2020-06-26 Thread Marvin Renich
When building a command with go build that imports modules, does the resulting executable contain information about which modules are included as well as their versions? If so, is there a tool available to extract that information from the executable? Can the information be retrieved from within

Re: [go-nuts] Re: political fundraising on golang.org!

2020-06-19 Thread Marvin Renich
* Marvin Renich [200619 11:17]: > You post a banner within the Go community that is off topic and is ^ Just to be clear, the "you" in this paragraph is not you, Ian, personally. I am referring collectively to the maintainers of the web sites and mailing lists in their offici

Re: [go-nuts] Re: political fundraising on golang.org!

2020-06-19 Thread Marvin Renich
* Ian Lance Taylor [200619 00:20]: > It's an important discussion, but having it on golang-nuts is not working. > > It can continue off-list. You post a banner within the Go community that is off topic and is highly controversial (this thread is clear evidence of that). You then squelch

Re: [go-nuts] political fundraising on golang.org!

2020-06-15 Thread Marvin Renich
[Note To and CC] Please consider this a formal request for the Go Project Stewards to review the website banners being discussed in this thread and to make a determination that these banners are causing divisiveness in the Go Community and have offended some, and that the banners' content is

Re: [go-nuts] political fundraising on golang.org!

2020-06-15 Thread Marvin Renich
* Sam Whited [200615 09:34]: > This is an important issue about the Go Community and who feels welcomed > here, which is also covered by this mailing list. This is _so_ wrong. The evidence that this banner has caused substantial divisiveness and offended many members of the Go community is

Re: [go-nuts] political fundraising on golang.org!

2020-06-15 Thread Marvin Renich
* 'Axel Wagner' via golang-nuts [200614 20:15]: > No, what you said is, that objecting to the banner may not be *political*. > You didn't mention parties and neither did I. And I stand by my statement, > that objecting to the banner *is* inherently a political act. And that > claiming to object

Re: [go-nuts] Re: help understanding weird Benchmark results

2020-05-19 Thread Marvin Renich
* Warren Bare [200519 13:53]: > OK, I added a sum of the rand to the demo code and the results are the > same. Since it is displaying the sum, it seems clear that the code is not > optimized away. > > Again, I am NOT trying to time each iteration of the loop. This is a > minimal

Re: [go-nuts] Type Assertion on File type

2020-05-07 Thread Marvin Renich
* André kouamé [200507 12:57]: > I want to check, if the value return by my function has the type *os.File > This my code : > func createFile(filename string) (*os.File, error) { > f, err := os.OpenFile(filename, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644) > return f, err > > } > //Test code >

Re: [go-nuts] keyword func

2020-04-27 Thread Marvin Renich
* レミリア・スカーレット [200427 12:46]: > Why you need to write a "func sum(a, b int) int {...}", not "sum(a, b int) > int {...}"? > It seems to me that one could do without func keyword. I believe another reason is that the Go language designers decided that every top-level syntax element begins with a

Re: [go-nuts] Go Tour ok?

2020-04-21 Thread Marvin Renich
* Anssi Porttikivi [200421 08:57]: > I had to run the Go Tour locally, because the web version gives me odd > "timed out" and "build failed" (with no reason) errors > indeterministically... Is it just me? I was having the same trouble earlier today. The build (or run) was timing out, and the

Re: [go-nuts] Re: "Go build failed." in Go tour requires explicit Kill

2020-04-16 Thread Marvin Renich
* Brian Candler [200416 12:20]: > I've noticed this too. This is with the tour, rather than play.golang.org. > > To reproduce (I'm using Chrome 80 under macOS 10.14): > > * Go to a tour page which doesn't compile, e.g. > https://tour.golang.org/methods/25 > * Click Run > * At this point it

Re: [go-nuts] Re: wording in Go tour, methods/19

2020-04-16 Thread Marvin Renich
* Volker Dobler [200416 02:28]: > On Wednesday, 15 April 2020 17:58:11 UTC+2, Marvin Renich wrote: > > > > In the Go tour at https://tour.golang.org/methods/19 it says > > > > The error type is a built-in interface similar to fmt.Stringer: > > I agree

[go-nuts] "Go build failed." in Go tour requires explicit Kill

2020-04-15 Thread Marvin Renich
In the Go tour, what is the purpose of requiring the user to explicitly press the "Kill" button when the build fails? This seems completely unnecessary to me. If this is just a natural consequence of the internal implementation, it would, in my opinion, be well worth the effort to make a failed

[go-nuts] wording in Go tour, methods/19

2020-04-15 Thread Marvin Renich
In the Go tour at https://tour.golang.org/methods/19 it says The error type is a built-in interface similar to fmt.Stringer: The words closest to "similar to" are "built-in interface", implying that the way error is similar to fmt.Stringer is that it is a built-in interface, which it clearly

Re: [go-nuts] go run requires internet connection?

2020-04-08 Thread Marvin Renich
* Tanmay Das [200408 12:17]: > Hey Gophers, > My very first post here. > > Today I faced an unexpected power outage and I wanted to tinker with Go a > little bit. I wrote a simple hello world program and ran > go run helloworld.go > > Strangely the code didn't run. In fact, the terminal

Re: [go-nuts] Should it panic when set a channel to nil concurrently

2020-03-02 Thread Marvin Renich
* Yuan Ting [200301 23:50]: > I write a simple program likes below and it triggers a data race alarm with > -race flag. But no matter how I run, this program will not panic. I know it > is legal to receive messages from nil channels, but I don't quite > understand why this program does not

Re: [go-nuts] doubt about reflect.Type.String and empty interface

2020-01-07 Thread Marvin Renich
* Manlio Perillo [200106 18:57]: > I wrote another test https://play.golang.org/p/hoTAnijCfg1. > Now it is clear why the first entry can only print nil for the type > and for the value. > > However printf %v verb prints nil for both an empty interface and an > interface with a dynamic value of

Re: [go-nuts] Re: bufio.Reader.Buffered returns 0

2019-12-16 Thread Marvin Renich
* Ian Lance Taylor [191215 23:05]: > The Buffered method [snip] tells you how > many bytes you can Read without causing a call to the underlying > Reader. I think this would be a significant improvement over the current ambiguous documentation. It should adequately dispel any unrealistic

Re: [go-nuts] Re: What is the correct way to access/modify slice elements concurrently

2019-11-13 Thread Marvin Renich
* burak serdar [191112 12:45]: > Is there a guarantee that the compiler will not reorganize > instructions around an atomic read/write? That is: > > i++ > k:=atomic.AddInt32(,1) > > Is there a guarantee that the compiler won't rewrite this as: > > k:=atomic.AddInt32(,1) > i++ First, from one

Re: [go-nuts] Re: What is the correct way to access/modify slice elements concurrently

2019-11-12 Thread Marvin Renich
* Robert Engels [191112 12:59]: > The bug I referenced discusses the current problem with the MM > specification. You are making assumptions that are not supported by > the current MM, but as the bug points out, that is the current > behavior. I can see that point of view, and I don't think it

Re: [go-nuts] What is the correct way to access/modify slice elements concurrently

2019-11-12 Thread Marvin Renich
* Robert Engels [191112 13:44]: > Sorry, at work so I need to use the 'web mail' interface and it > doesn't appear to be including them when I reply. Understood. I'll just try to follow the threading as best as I can. ...Marvin -- You received this message because you are subscribed to the

Re: [go-nuts] What is the correct way to access/modify slice elements concurrently

2019-11-12 Thread Marvin Renich
that display messages from the same thread together. Does your MUA not add this header???] * Robert Engels [191112 13:00]: > This is not the issue I am referring to, I am referring to > https://github.com/golang/go/issues/5045 > > -Original Message----- > >From: Marvin Renich >

Re: [go-nuts] What is the correct way to access/modify slice elements concurrently

2019-11-12 Thread Marvin Renich
[I almost missed this post because you did not reply to the thread.] * Robert Engels [191108 11:41]: > See https://github.com/golang/go/issues/10958 for using atomics in > tight/busy-wait loops. This doesn't have anything to do with atomics. Atomic operations are just one of many, many things

Re: [go-nuts] Re: What is the correct way to access/modify slice elements concurrently

2019-11-12 Thread Marvin Renich
There are two different viewpoints you can take. Either the Go Memory Model must stand alone, and any concurrency claims made by the language and standard library must be based on the limited set of operations defined in the GMM, or the GMM provides the definitions and provides a substantial, but

Re: [go-nuts] What is the correct way to access/modify slice elements concurrently

2019-11-08 Thread Marvin Renich
* burak serdar [191108 08:42]: > I was thinking about this. In general, it should be safe to replace > > Lock() > read/write one value > Unlock() > > with > > AtomicRead/Write > > Is that correct? The go memory model does not say anything about this. Yes. While others have argued that the

Re: [go-nuts] What is the correct way to access/modify slice elements concurrently

2019-11-08 Thread Marvin Renich
* Kasun Vithanage [191107 23:47]: > type Foo struct { > Alive bool > } > > type Bar struct { > Foos []*Foo > } > > func (b *Bar) CheckFoosAlive() { > for i := 0; i < len(b.Foos); i++ { > if b.Foos[i].Alive { > fmt.Println("Alive") > } > } > } > > func (b* Bar)

Re: [go-nuts] Need advice on AST formatting

2019-10-28 Thread Marvin Renich
* roger peppe [191028 04:49]: > On Sun, 27 Oct 2019, 02:52 Marvin Renich, wrote: > > I strongly encourage you to use > > > > var fset = token.NewFileSet() > > > > rather than > > > > fset := token.NewFileSet() > > > > Those two altern

Re: [go-nuts] Need advice on AST formatting

2019-10-26 Thread Marvin Renich
* Denis Cheremisov [191026 06:09]: > The answer was simple: > > var fset token.FileSet – wrong > > fset := token.NewFileSet() – right I believe I am in the minority here, but I am not a singleton minority. There are at least several of us who agree that «var» should be used over «:=» whenever

Re: [go-nuts] Re: Static methods

2019-10-18 Thread Marvin Renich
First, let me apologize for writing in a way that you took to be aggressive. That was definitely not my intention. My state of mind when I wrote it was conversational, not antagonistic, and I did not realize you would interpret it any other way. * gera...@cloudoki.com [191018 11:08]: > hey,

Re: [go-nuts] Re: Static methods

2019-10-16 Thread Marvin Renich
* gera...@cloudoki.com [191016 11:03]: > I'm not sure about its *idiomacity*, but namespacing should be a nice thing. > > On Tuesday, March 1, 2011 at 8:48:52 PM UTC, yiyus wrote: Do you realize you are responding to an eight-year-old thread? If you really feel a

Re: [go-nuts] Re: Extending an array 'The right way'. Guidence needed!

2019-10-15 Thread Marvin Renich
* thatipelli santhosh [191015 08:07]: > Hi Marvin, > > I am curious to know if we approx 10 ( we don't know exact amount of > slice entries) add to slice. Slice will grow based on our size of data > and underlying array size but doing this create multiple underlying arrays > (more memory

Re: [go-nuts] Re: Extending an array 'The right way'. Guidence needed!

2019-10-15 Thread Marvin Renich
P.S. If you are still having trouble after reading the responses to your query, use the go playground (https://play.golang.org/) to create a simple program that demonstrates what you are trying, and post the link you get from clicking the "Share" button, and explain what you would like the output

Re: [go-nuts] Re: Extending an array 'The right way'. Guidence needed!

2019-10-15 Thread Marvin Renich
[When you are replying to someone else's message, reply to that message, not your original message. Your reply lost the context of the message to which you were replying (Jan Mercl's).] * Stuart Davies [191015 07:24]: > My goal is to contain a list of integers that may extend to possibly a >

[go-nuts] WAIT_TIMEOUT inconsistency in golang.org/x/sys/windows

2019-09-26 Thread Marvin Renich
In golang.org/x/sys/windows, the WAIT_* return codes from WaitForSingleObject and WaitForMultipleObjects are defined as untyped integer constants except for WAIT_TIMEOUT, which is a syscall.Errno. All the other syscall.Errno values less than 1700 (the first RPC_ error) begin with ERROR_. The

Re: [go-nuts] Regarding strings replace functions issues

2019-08-27 Thread Marvin Renich
* Durga Someswararao G [190827 14:07]: > Hi, > > Can anyone help me in this case. > > I was reading byte data(array of bytes) from another process and converted > that data to string. Now I am trying to replace escape sequences \n with > strings.Replace function but golang not detecting it. >

Re: [go-nuts] Split a empty string will get a one element array?

2019-08-08 Thread Marvin Renich
* Kurtis Rader [190807 18:43]: > Please don't respond to threads that are seven years old. Having said that > the behavior is reasonable and the behavior you and the O.P. expect is not > reasonable. Consider the following examples: > > result := strings.Split("abc", "") > result :=

Re: [go-nuts] Testing using mock functionality

2019-07-22 Thread Marvin Renich
* wylderke...@gmail.com [190722 01:11]: > I'm new to go (and new to unit testing) and have a question about how to > test my code. I have a package that uses a library, with a kinda big > interface , let's > call it A. I don't use all the

Re: [go-nuts] Let's play

2019-07-12 Thread Marvin Renich
* Ali Hassan [190712 12:56]: > > If you curious about check out the link below > https://koohinoorgo.blogspot.com/2019/07/methods-bind-to-special-type-of-receiver.html The only thing about this message that does not look like a phishing or Trojan attack is the end of the URL. The subject and

Re: [go-nuts] [cgo ] Export go function to C - illegal character

2019-06-26 Thread Marvin Renich
* nicolas_boiteux via golang-nuts [190626 13:19]: > /* > #include > #include > #include > extern void __stdcall RVExtension(char *output, int outputSize, const char > *function); > */ > > //export RVExtensionVersion > func RVExtensionVersion(output *C.char, outputsize C.size_t) { >

Re: [go-nuts] [cgo ] Export go function to C - illegal character

2019-06-26 Thread Marvin Renich
* nicolas_boiteux via golang-nuts [190626 12:15]: > i have some news. > > With this kind of declaration > extern void __fastcall RVExtension(char *output, int outputSize, const char > *function){ > goRVExtension(output, outputSize, function); > }; > as you can see in error message this

Re: [go-nuts] [cgo ] Export go function to C - illegal character

2019-06-23 Thread Marvin Renich
* nicolas_boiteux via golang-nuts [190623 15:33]: > Precisly, i don't know what is this @12, and nobody can explain this :( > It's for a windows build and the dll is load by arma game. The leading '_' and trailing '@' followed by a number is the __stdcall decoration for a C name in the produced

Re: [go-nuts] bogus "missing return at end of function"

2019-06-09 Thread Marvin Renich
* Marvin Renich [190609 20:40]: > Is it already a known issue that a «for [true] { ... }» loop whose only > exit path is through return statements inside the loop (i.e. no break > statement) will produce the compiler error "missing return at end of > function" if you d

[go-nuts] bogus "missing return at end of function"

2019-06-09 Thread Marvin Renich
Is it already a known issue that a «for [true] { ... }» loop whose only exit path is through return statements inside the loop (i.e. no break statement) will produce the compiler error "missing return at end of function" if you don't put a meaningless "return ..." statement after the loop? If

Re: [go-nuts] make an empty slice

2019-06-06 Thread Marvin Renich
* sasikala tholisam [190606 09:49]: > > test []Exam > > type Exam struct{ > Time uint32 > LogType uint32 > Data [32]byte > } > > test is a slice of []Exam..It should be an empty slice...how to make test > as empty? After changing the first line to var test []Exam your code will

Re: [go-nuts] How to run a go method on multiple cores ?

2019-05-17 Thread Marvin Renich
Sorry for the much delayed response. I have not had enough time lately! * Nitish Saboo [190508 05:48]: > "Do you mean "log/syslog" from the standard library? What does > initialize do?" > > >>I have installed syslog-ng parser on my Linux box and I am planning you > use syslog-ng parser and

Re: [go-nuts] How to run a go method on multiple cores ?

2019-05-09 Thread Marvin Renich
* Nitish Saboo [190508 05:48]: Please remove me from the CC on this thread; I am subscribed to the list. I explicitly set Reply-To, which was not respected, and now I am getting duplicates of every mail, with one copy in my personal mail and one copy in my list mail folder. In general, it is a

Re: [go-nuts] Re: Does fmt.Fprint use WriteString ?

2019-05-08 Thread Marvin Renich
[Sorry for the late reply; I was having technical difficulties!] * Louki Sumirniy [190503 10:39]: > A lot of people clearly don't know this, also - there is a builtin print() > and println() function in Go. If the output is stdout, these are probably > the most efficient ways to thow strings

Re: [go-nuts] How to run a go method on multiple cores ?

2019-05-07 Thread Marvin Renich
* Nitish Saboo [190507 14:07]: > Thanks Michel for your detailed response. > I am initialising the syslog engine. Do you mean "log/syslog" from the standard library? What does initialize do? > var obj1 parser = initalize() > var obj2 parser > go func() { > obj2 = initalize() > }() You have

Re: [go-nuts] go execution speed for float64 based calculations vs float32

2019-04-22 Thread Marvin Renich
* lgod...@gmail.com [190421 21:56]: > ?? On 64-bit CPUs does anyone have any experience comparing the run-time > speed of float64 based calculations vs float32 ? > > Some of my C-code when translated to Go-code seems to run noticeably > slower, so I'm wondering if I can speed things up by

Re: [go-nuts] go execution speed for float64 based calculations vs float32

2019-04-22 Thread Marvin Renich
* lgod...@gmail.com [190422 01:57]: > I note that this issue has been dealt with in a previous post > https://groups.google.com/forum/#!topic/golang-nuts/n12khle-mlY > The gist of which seems to suggest that 32-bit is faster than 64 That thread was specific to integer remainder (%) and is

Re: [go-nuts] ed25519 signature, expected non-deterministic

2019-04-19 Thread Marvin Renich
* Dave Cohen [190419 10:25]: > I'm working on code that signs a message with an ed25519 key. > > I expected that when signing the same message over and over, I'd get a > different signature each time. > > But I find when I run the test (below) more than once, I get the same > signature bytes

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

2019-04-16 Thread Marvin Renich
* peterGo [190416 09:23]: > Marvin Renich, > > "I would interpret the phrase," "I think the phrase," and "I prefer" are > your personal interpretation, thoughts, and preference. Go prefers standard > interpretations: US words, spelling, grammar, an

[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 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

Re: [go-nuts] A value copy will occur when executing for range xxx?

2019-04-03 Thread Marvin Renich
* mountain...@gmail.com [190403 05:10]: > package main > > func main() { > b := []int{1} > > bb := make([]*int, 0, 1) > for k, v := range b { The above range clause will assign to k the index of the current element, and it will assign to v a copy (as if v = b[k]) of the element at that index.

Re: [go-nuts] Confusing Behavior When Compiling an Assignment Using a Map

2019-03-29 Thread Marvin Renich
* jlforr...@berkeley.edu [190329 15:28]: > Thanks everyone for responding! > > However, in the case that I illustrated there is no such problem. I > would have thought that the language would allow this construct with > any expression on the right side, as long as it only has one map > access. >

Re: [go-nuts] Confusing Behavior When Compiling an Assignment Using a Map

2019-03-29 Thread Marvin Renich
* jlforr...@berkeley.edu [190329 11:16]: > I get the error > > assignment mismatch: 2 variable but 1 values > > for the assignment statement in Part 2 but the assignment statement in > Part 1 compiles. Both assignment statements have the same number of > values, but it appears that referencing

Re: [go-nuts] email body not showing up

2019-03-21 Thread Marvin Renich
* pradam [190321 02:27]: > I have implement below code, but body not showing up, so whats wrong > with the code? IWFM. I only changed the server, sender email and recipient email, and the mail was delivered (without a Subject) with the correct body. You didn't get any errors? You say the body

Re: [go-nuts] cancelCtx: why does not return c.done directly?

2019-03-01 Thread Marvin Renich
* Robert Engels [190301 15:07]: > I am pretty sure it is the memory model unless there is other code in > the stdlib that sets the dove back to nil - which wouldn’t make sense > since the channel should be unique to the context instance and that > would allow multiple done channels to be created.

Re: [go-nuts] cancelCtx: why does not return c.done directly?

2019-03-01 Thread Marvin Renich
* dongshujin.be...@gmail.com [190301 08:50]: > The following code is a snippet of the context pkg. > cancelCtx.Done(): > > func (c *cancelCtx) Done() <-chan struct{} { >c.mu.Lock() >if c.done == nil { > c.done = make(chan struct{}) >} >d := c.done >c.mu.Unlock() >

Re: [go-nuts] efficient random float32 number generator?

2019-02-26 Thread Marvin Renich
* Louki Sumirniy [190226 06:22]: > Assuming there is bytes in the system's entropy pool, you can also skip the > scrambling step, though I don't know what overhead consuming these bytes > entails compared to a standard PRNG. Then the biggest part of it is making > the raw bytes into float. I'm

Re: [go-nuts] lock for assigning to different elements of an array

2019-02-01 Thread Marvin Renich
* johnmr...@gmail.com [190131 23:50]: > > Writing to adjacent memory locations [i.e. different array elements, from > > different goroutines] will cause false sharing between CPU caches. This is > > a performance, not a correctness issue. > > I'm looking to make an array of thread-safe

Re: [go-nuts] About 64bits alignment

2019-01-26 Thread Marvin Renich
* Ian Lance Taylor [190125 18:11]: > On Fri, Jan 25, 2019 at 2:59 PM wrote: > > I still can't find anything "authoritative and unambiguous" on this. > > Therefore apps are going to be released with bugs in them. Can > > someone please say specifically when it is _not_ safe to use 64-bit > >

Re: [go-nuts] "All types implement the empty interface"

2019-01-23 Thread Marvin Renich
* 伊藤和也 [190123 00:27]: > I found the explanation "All types implement the empty interface". > https://golang.org/ref/spec#Interface_types > So an empty interface also implements an empty interface? and again the > empty interface implements an empty interface and the empty inter... > What I

Re: [go-nuts] errgroup example without channels

2018-12-03 Thread Marvin Renich
* Mu11 [181203 11:47]: > I saw the example > of > errgroup in godoc, and it makes me confused that it simply assigns the > result to global results instead of using channels in each search routines. > Heres the code: > >

Re: [go-nuts] When set time.Location, will be detected Data Race

2018-11-30 Thread Marvin Renich
* Ian Lance Taylor [181130 01:01]: > On Thu, Nov 29, 2018 at 9:47 PM wrote: > > The feature of golang is goroutine, and it is a normal situation that get > > time in different goroutine. > > But only can set time.Location in one goroutine. So the Data Race is > > inevitable. > > > > And there

Re: [go-nuts] Regarding contracts

2018-10-25 Thread Marvin Renich
* Andy Balholm [181024 17:52]: > What I’m doing with structural contracts is basically the same as what > you’re doing with struct and interface types as contracts, except that > (I hope) the syntax is a little clearer. > > I added the support for operators basically to avoid having the >

Re: [go-nuts] Regarding contracts

2018-10-22 Thread Marvin Renich
> Ian Denhardt : > > But I think fundamentally folks have to > > make choice: do we want to be able to write `<` for user defined types, or > > do > > we want to be able to look at the `<` operator and know for certain that > > it's > > not calling a method? You can't have both. You can have

Re: [go-nuts] Regarding contracts

2018-10-22 Thread Marvin Renich
* Burak Serdar [181018 15:08]: > tbh, I am not trying to avoid operator overloading, I am trying to > avoid the contracts. With operator overloading, you can write: > > func F(a,b type T like(int,X)) { >if a ... >} > } > > provided X is a type that supports <. Are you trying to

Re: [go-nuts] Generics: an unwelcome conclusion and a proposal

2018-10-17 Thread Marvin Renich
* Ian Lance Taylor [181016 17:59]: > The contract system in the generics design draft does not have this > problem. It may have other problems, but it doesn't have this one. I haven't finished reading the draft (I got to the beginning of the Contract Details section when it was first mentioned

Re: [go-nuts] Casting Back from nested Struct

2018-10-10 Thread Marvin Renich
* Chris Hopkins [181010 12:04]: > Hi, > I appreciate this is not possible, but realised I never understood why (so > have just been working around it). > Example code at: > https://play.golang.org/p/BgFL9T0KiC7 > > I can create a struct with other structs as a member. I then get all the >

Re: [go-nuts] Traverse directory without infinite loops while following symlinks

2018-10-07 Thread Marvin Renich
[I've set reply-to to include you (per your reply-to) but to exclude me; I prefer to read my list mail on the list rather than in my personal inbox.] * rob solomon [181006 15:17]: > I've been trying to do something simple like this, but I'm not interested in > following symlinks.  Here I just am

Re: [go-nuts] Traverse directory without infinite loops while following links

2018-10-04 Thread Marvin Renich
* EricR [181004 13:33]: > Hi! I'm new to Go and need to do something with each file in directories. > Symlinks need to be followed. I've tried filepath and a few popular > libraries and they either crash with segfaults on my system, do not follow > symlinks or do not prevent infinite loops. >

Re: [go-nuts] Character Replacement/Algorithm for Replacement

2018-08-30 Thread Marvin Renich
* Michael Jones [180830 11:44]: > The task to "translate a string through a table" is common. It is a single > computer instruction (TR) in the IBM 360 and was extended over time with > related instructions for conversion in and out of UTF-8, testing before and > after translation, and expanded

Re: [go-nuts] Re: Are Go floats smarter?

2018-08-30 Thread Marvin Renich
* José Colón [180830 06:53]: > Very interesting. So would it be a good idea to use these types of untyped > constant calculations for financial applications, or instances where one > would use the math.big package? Not likely. You would have to know at compile time the exact values you wanted

Re: [go-nuts] Character Replacement/Algorithm for Replacement

2018-08-30 Thread Marvin Renich
* Tamás Gulácsi [180830 01:17]: > An even faster lookup is creating a [256]byte array for the replacements, > having the 9 replacements candidates _position_ having the replacements, > all others the identity: > > // prepare the lookup table > var a [256]byte > for i := 0; i<256; i++ { >

Re: [go-nuts] Re: go/format ouputs spurious newlines

2018-08-14 Thread Marvin Renich
* n...@mit.edu [180814 11:43]: > The documentation can be interpreted as you say. I do not see how you can interpret it otherwise. > If the resulting AST is subsequently inserted into a larger AST and then > serialized, the source that is output can be syntactically invalid. > > It is

Re: [go-nuts] why my program will panic?

2018-08-14 Thread Marvin Renich
* sheepbao [180814 10:53]: > Thank you for your detailed answer. > I thought it would crash in this line (b.Z = "zz") of code. But it dose not > happen and the program print "zz". > I don't understand why this program crash in return, not in b.Z = "zz". > Because I agree with your opinion, The

Re: [go-nuts] Re: go/format ouputs spurious newlines

2018-08-14 Thread Marvin Renich
* n...@mit.edu [180814 09:47]: > The documentation for parser.ParseExpr says that the position information > in the AST it returns "is undefined". I opserved the result as having > position information. This looks like a bug. > > https://play.golang.org/p/tpzqDF3EZ_S > > demonstrates this

Re: [go-nuts] why my program will panic?

2018-08-14 Thread Marvin Renich
* sheepbao [180813 23:45]: > go version > go version go1.10.2 darwin/amd64 > > test code: > > func TestPoint(t *testing.T) { > type A struct { > X int > Y string > } > type B struct { > X int > Y string > Z string > } > > a := A{X: 2,

Re: [go-nuts] Re: looking for a flexible file path resolver

2018-08-07 Thread Marvin Renich
* DrGo [180806 18:37]: > There are situations where you need to check (and report back to the user) > for file existence no matter how you do that (using Stat or by attempting > to open or create it). I agree completely. However, doesn't os.Stat do what you want here simply and portably? If

Re: [go-nuts] Re: looking for a flexible file path resolver

2018-08-06 Thread Marvin Renich
* DrGo [180806 02:00]: > Thanks, > filepath.Abs does some of what I want, but as far as I could tell, it does > not handle resolving relative paths Does this code help out? if filepath.IsAbs(somepath) { somepath = filepath.Clean(somepath) } else { var wd, err = os.Getwd() if err !=

Re: [go-nuts] Type "slicing"

2018-08-01 Thread Marvin Renich
* Paul J. Lucas [180728 14:43]: > First, please forgive the length of the example code. It's as small a > distillation of my original code as I could manage that still > illustrates the issue. The code is here: > > https://play.golang.org/p/MjyFize1iOW > > [trimmed] > > The problem is

Re: [go-nuts] float accuracy when calculating Fibonacci numbers

2018-05-01 Thread Marvin Renich
* andrey mirtchovski [180430 17:41]: > > math.Pow does not give as precise answers as the C++ std lib. > > math pow doesn't just multiply X by itself Y times, it uses a > different algorithm: > > https://golang.org/src/math/pow.go#L40 Sure, I understand that. However,

Re: [go-nuts] float accuracy when calculating Fibonacci numbers

2018-04-30 Thread Marvin Renich
* Michael Jones [180430 13:54]: > Andrey, that's great! > > On the Fibonacci series evaluation, let's make sure that we're all doing > the same calculation. For completeness and safety, let's skip all library > values and derived values. Here are more-than-sufficient

Re: [go-nuts] float accuracy when calculating Fibonacci numbers

2018-04-30 Thread Marvin Renich
* Yuval Lifshitz [180430 02:02]: > It seems like go and C++ are doing something different regarding floating > point arithmetic, but I cannot say one is better than the other. It is just > the that C++ consistently overshoots (hence truncation work), and go > consistently

Re: [go-nuts] Re: panic propagation can be blocked by blocking defer function

2018-04-02 Thread Marvin Renich
* 'Bryan Mills' via golang-nuts [180402 15:10]: > This is indeed a subtle pattern, but it's not clear to me how often it > comes up in practice, and preventing deferred function calls from blocking > could result in all kinds of other unwanted side effects. I'd

Re: [go-nuts] Re: About a channel detail, bug, defect, or intended?

2018-03-26 Thread Marvin Renich
It seems that you understand why you are seeing the behavior you reported, but you are questioning whether the spec either does or should guarantee that reading from a channel with a goroutine waiting to send on that channel will fill the buffer as an atomic part of the read. As others have said,

Re: [go-nuts] Is there some kind of memory write protection mechanism?

2018-02-25 Thread Marvin Renich
* d...@veryhaha.com [180225 11:37]: > I think I get it. > Because the above program tries to modify the constant (or program) zone, > which is not allowed. > The following program works: But, note that the language spec does not guarantee it to work. The compiler is free to

Re: [go-nuts] Is this a bug?

2018-02-25 Thread Marvin Renich
The point to remember is that each value of a concrete type has exactly that one concrete type, while each value of an interface type has exactly one interface type and one concrete type. It is also important to note that there is a distinction between "assignability" and "type-assertiblity". *

  1   2   >