Re: [go-nuts] how to merge different struct to one struct

2019-08-24 Thread jake6502
On Saturday, August 24, 2019 at 3:39:27 AM UTC-4, Lee Rick wrote: > > think that there are two struct, they have different fields, hope that > there has a function merge(a,b interface{}) interface{}, input param are > any two struct, they may have same-type, or have different-type. output >

[go-nuts] Re: Empty cpu profile file?

2019-08-21 Thread jake6502
On Tuesday, August 20, 2019 at 7:58:29 PM UTC-4, joe mcguckin wrote: > > Using Dave Cheney's profile package to figure out the execution path of a > library I'm trying to understand. > > The application starts, (it's a server), I hit ^c after a couple of > minutes, and the console says > >

[go-nuts] Re: What did you see at GopherCon 2019 (San Diego)?

2019-08-06 Thread jake6502
On Tuesday, August 6, 2019 at 7:35:08 AM UTC-4, Akram Ahmad wrote: > > For me, attending GopherCon 2019 recently in San Diego was tremendous fun > (The Gopher community is so amazing!) > > This is what I saw, the following being *the coordinates* to my > (incredibly unofficial) writeup: > >

[go-nuts] Re: go 1.13 changes

2019-07-29 Thread jake6502
Also the blog: Next steps toward Go 2 On Sunday, July 28, 2019 at 1:49:31 PM UTC-4, peterGo wrote: > > rob solomon, > > Go 1.13 Release Notes: https://tip.golang.org/doc/go1.13 > > peter > > > On Sunday, July 28, 2019 at 12:02:14 PM UTC-4, rob wrote: >>

[go-nuts] Re: Preparing defaults for multiple-values-returning functions

2019-07-23 Thread jake6502
(Previous post deleted to to premature "Post") My 2 cents. I'm a seasoned Go programmer with years of professional Go experience, and decades of coding work. Personally, I would avoid goto if possible. It may "have been a best practice for a long time" in C/C++ and other languages. But in Go,

[go-nuts] Re: Preparing defaults for multiple-values-returning functions

2019-07-23 Thread jake6502
On Monday, July 22, 2019 at 2:51:43 PM UTC-4, Tong Sun wrote: > > I want to define a default set of values for the multiple-values-returning > function, so when doing error checking along the way, I can return such > default set when things go wrong. > > How can I do that? > Is it possible to

Re: [go-nuts] Tools or debug options for debugging 'Error in `bin/main': double free or corruption (fasttop)' in cgo

2019-07-15 Thread jake6502
> > I am a beginner with GO and cgo, and have never dealt with C corruption > issues. > > First, I would try really hard to find a pure go solution to your problem, or next best, a solution that uses a 3rd party go package that handles the cgo for you. I understand that this may not be

Re: [go-nuts] Avoiding resource leaks with racing channels

2019-07-10 Thread jake6502
On Tuesday, July 9, 2019 at 12:27:32 PM UTC-4, Dan Eloff wrote: > > I couldn't use <-channel.Close since in my case the goroutine isn't > guaranteed to have something sent, so that would leak goroutines. I added a > cleanup goroutine to scan timed-out channels and close them, which solves >

[go-nuts] Re: is there a goroutine scope global veriable ?

2019-06-19 Thread jake6502
This has been discussed many times before. Searching "local storage" on this group brings up many discussions, including: https://groups.google.com/d/topic/golang-nuts/Nt0hVV_nqHE/discussion https://groups.google.com/d/topic/golang-nuts/_Vv7Bzn8yH4/discussion

[go-nuts] Re: Scheduling - find the overlap size of two sequential date ranges and determine the actual dates of included in the intersection

2019-06-17 Thread jake6502
On Sunday, June 16, 2019 at 12:52:54 PM UTC-4, John More wrote: > > Updated playground code > https://play.golang.org/p/qHufIG5ppww > > On Sunday, June 16, 2019 at 12:48:25 PM UTC-4, John More wrote: >> >> I have created a program to solve this problem ( >> https://play.golang.org/p/BueQBahUUbk)

Re: [go-nuts] Pointer Method Receiver

2019-06-17 Thread jake6502
On Sunday, June 16, 2019 at 5:29:49 PM UTC-4, andrey mirtchovski wrote: > > Hi Ali, > > I understand your desire to provide useful information about Go in > blog posts. This is commendable. However let's try to keep this list > for technical issues and keep empty posts containing just a link

[go-nuts] Re: global var available in different files (same package)

2019-06-07 Thread jake6502
On Friday, June 7, 2019 at 2:12:22 PM UTC-4, Natxo Asenjo wrote: > > > > On Friday, June 7, 2019 at 6:07:09 PM UTC+2, jake...@gmail.com wrote: >> >> >> >> It is unclear what the problem is. Global variables will be accessible >> from any file that is part of package "main". As you said, you

[go-nuts] Re: global var available in different files (same package)

2019-06-07 Thread jake6502
On Thursday, June 6, 2019 at 3:07:22 PM UTC-4, Natxo Asenjo wrote: > > hi, > > I'd like to define a couple of global variables in a small cli app. The > app has a few files but it's not large. > > What I'd like is to use cli flags to define options, and those options > should be available for

[go-nuts] Re: A good indicator of code quality

2019-06-07 Thread jake6502
On Thursday, June 6, 2019 at 3:58:19 PM UTC-4, Carl wrote: > > I'd like to know what people are using to measure the quality of their Go > code bases and why. Specifically, I'm asking if: > >1. There is a way to score a code base on quality that works with >idiomatic Go >2. Use this

[go-nuts] Re: pprof - Trouble getting any data from pprof.StartCPUProfile()

2019-05-21 Thread jake6502
On Tuesday, May 21, 2019 at 12:54:32 PM UTC-4, Russtopia wrote: > > Hi all, > > I've tried running some of my Go code using CPU Profiling enabled as > described at > > https://blog.golang.org/profiling-go-programs > > and > > https://golang.org/pkg/runtime/pprof/#StartCPUProfile > > .. I'm

[go-nuts] Re: net.InterfaceAddrs() error and returned addr slice

2019-05-16 Thread jake6502
On Wednesday, May 15, 2019 at 5:00:26 PM UTC-4, Vasiliy Tolstov wrote: > > Hi! I have error from net.InterfaceAddrs() like route ip+net: no such > network interface > i think that error happened because i have docker running that > creates/deletes interfaces in my system. > My question is -

[go-nuts] Re: guarantees on net.Conn and net.UDPConn Read

2019-05-13 Thread jake6502
On Thursday, May 9, 2019 at 2:54:17 AM UTC-4, kortschak wrote: > > The Conn and UDPConn Read methods look like io.Reader Read methods, but > there is no explicit claim that Conn is an io.Reader. Are the Read > methods of these two types identical in behaviour to io.Reader? > I can not say

Re: [go-nuts] What happens to global vars when main() ends ?

2019-05-04 Thread jake6502
On Friday, May 3, 2019 at 9:44:05 PM UTC-4, lgo...@gmail.com wrote: > > I'm currently working on a specialized encryption system where the keys > are global... > More importantly, I've been unable to locate any decent on-line docs > describing exactly how Go GC works from a functional

Re: [go-nuts] Is it possible to simplify this snippet?

2019-05-01 Thread jake6502
On Wednesday, May 1, 2019 at 8:41:46 AM UTC-4, Jan Mercl wrote: > > On Wed, May 1, 2019 at 2:37 PM гусь > > wrote: > > > > if rl.IsKeyDown(rl.KeyA) { > > p.Rect.X -= 1 > > } > > if rl.IsKeyDown(rl.KeyD) { > > p.Rect.X += 1 > > } > > if rl.IsKeyDown(rl.KeyW) { > > p.Rect.Y -= 1 > > }

[go-nuts] Re: Parsing Raw Syslog messages

2019-04-25 Thread jake6502
This group works on a longer timeframe. It is not uncommon for it to take a day or two to get a good response. Bumping your post 8 hours later is definitely considered bad etiquette here. On Thursday, April 25, 2019 at 4:57:04 AM UTC-4, Nitish Saboo wrote: > > Hi, > > I want to parse raw

[go-nuts] Re: Is there a way to force to pass some function or error check when Debugging?

2019-04-24 Thread jake6502
On Tuesday, April 23, 2019 at 1:43:52 AM UTC-4, hui zhang wrote: > > I am debugging a linux server program in local mac machine. > some code related to environment check , such as check mount point etc. > > I want to pass this check , how ? > >- I try it set return error var to nil. but

[go-nuts] Re: gcwaiting=1 will causes block all the goroutines?

2019-04-11 Thread jake6502
On Wednesday, April 10, 2019 at 10:44:38 PM UTC-4, mount...@gmail.com wrote: > > Thank you very much for your meticulous reply. I basically understand the > scheduling mechanism, but I still don’t understand the third paragraph. > > It is "It is also important to note that the behavior of

[go-nuts] Re: gcwaiting=1 will causes block all the goroutines?

2019-04-10 Thread jake6502
As Ian said, your question is not completely clear. I think you are Saying that "I got scheduled!" prints 3 times, then the program appears to "hangs" on the runtime.GC() call. To start with, it is usually helpful to create a *minimal *program when dealing with questions like this. Your

[go-nuts] Re: Using Closures to Generate Code On the Fly

2019-04-04 Thread jake6502
Looking at https://git.parallelcoin.io/loki/gists/src/commit/d6cabfd0933d0cda731217c371e0295db331ebb1/tailrecursion-generic.md

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

2019-03-29 Thread jake6502
Yes, that is expected. The right hand side of the assignment is `b[1].code`. That is a single value. The "magic" that allows a two value return from a map lookup does not carry through to more complex expressions that use the value from that lookup. It would get confusing really fast if it

[go-nuts] Re: [ANN] another attempt at desktop ui

2019-03-29 Thread jake6502
No mention of what platforms it supports. You may want to add that to the docs also. On Friday, March 29, 2019 at 5:46:29 AM UTC-4, Johann Freymuth wrote: > > Over the last few months I've tried to write a desktop GUI library that > takes a slightly different approach to traditional GUI

[go-nuts] Re: rand.Rand.Seed() vs rand.NewSource()

2019-03-27 Thread jake6502
Following up on Ian's post. It is generally a good idea to go to the playground and make a minimal working "program" to demonstrate your question before posting. In doing so you would have discovered that the zero value of a rand.Rand can not be used, and will panic.

[go-nuts] Re: Need Help- Suddenly my unit test stop working

2019-03-25 Thread jake6502
First off, there is something really wrong with your post. Colors make it almost unreadable. Please stick to non-colored (black) text, and for output text please paste text directly, or use the code block feature provided by the google groups website. Have you looked at the file

[go-nuts] Re: Launching a windows app from command line with paths in arguments problem

2019-03-21 Thread jake6502
It is likely that the spaces before the command line arguments is confusing the Chrome parser. Try removing them for every item in Args, and it may work. On a style note, I would use: AppCommand:= `C:\Users\User\AppData\Local\Google\Chrome\Application\chrome.exe` instead of: AppCommand:=

Re: [go-nuts] Re: Deferring a close that can fail

2019-03-21 Thread jake6502
Two things to note about this. First, if the "everything else" deferred to might include a return statement, then this could result in the same "silent failure" behavior. Secondly - use this pattern with great caution. It is critical to confirm that a double close on ifDB is explicitly

[go-nuts] Re: panic at fmt.Printlb

2019-03-18 Thread jake6502
Can't say for sure without seeing additional code. But it looks like you have a race condition. It appears that the fmt.Println() is trying to print the map at the same time that you are modifying it. Your locks may prevent ForEachRemov() and FindAndRemove() from accessing the map at the

[go-nuts] Re: gdb go optimized out

2019-03-15 Thread jake6502
First off, we are always happy to have new users in the group. But one more bit of etiquette - Please don't post screenshots of text. Instead copy paste the text into the message. I like to use fixed width font, or put it in a code block. See the recent discussion at

[go-nuts] Re: gdb go optimized out

2019-03-14 Thread jake6502
First off. Please don't use a giant font in this group. It adds no valuable information, and makes it seem like you are yelling at the reader. I use delve not gdb, so I can not speak directly to that. I use -gcflags="-N -l", and so far it has always produced

[go-nuts] Re: How to retain environment in SSH

2019-03-11 Thread jake6502
Perhaps someone will magically understand your problem. But in general I would say that you should post more information if you want a good chance of a useful reply. Some tips: Please never post screenshots unless there is an overwhelming reason to do so. This is not one of those cases.

[go-nuts] Re: Go playground to support none-standard modules

2019-03-10 Thread jake6502
You can setup and run your own playground with https://github.com/golang/playground. I have not done it myself, but you could probably use that to do what you propose. On Saturday, March 9, 2019 at 9:50:15 PM UTC-5, Tong Sun wrote: > > I know Go playground does not support none-standard

[go-nuts] Re: why slice[len:len] okay, but slice[len] fail?

2019-03-08 Thread jake6502
The other answers to your original question are reasonable, and probably helpful. But I would also like to point out the definitive, though maybe less helpful answer to both your original question, and this new one. You see that behavior because the language specification says you should. Read

[go-nuts] Re: Go 1.12 installer on Windows 7 (x64) problem

2019-03-04 Thread jake6502
I have seen posts, unrelated to Go, about installers not recognizing Windows 7 SP1 as being installed. You did a screenshot of the update history, but you should also check that it is listed under Computer->Properties->Windows edition. See here

Re: [go-nuts] finding a way to convert "map[string]map[string]Somthing" into "map[string]interface{}"

2019-03-02 Thread jake6502
There have been multiple long discussions about converting []foo to []interface{} in this group. It is not possible. Most of the discussions apply just as well to your case. If you really need a "generic" function that does this, and can't convert as suggested by Louki, then you could use

[go-nuts] Re: Resolving methods on pointer types

2019-02-24 Thread jake6502
Maybe I'm misunderstanding, but the important thing is that foo never be copied. In your example, it is, in fact, *not *copied. See https://play.golang.org/p/U5EsDZSO3ce. Note that Foo is copied, but both f2 and f3 contain the same foo pointer, so the foo was never copied or moved. When

[go-nuts] Re: Resolving methods on pointer types

2019-02-24 Thread jake6502
On Sunday, February 24, 2019 at 4:31:10 PM UTC-5, Deomid Ryabkov wrote: > > Why can't Go resolve methods declared on the pointer receiver of the > destination type? > Because that is not how the language was designed. (I'm too busy to look up the spec here, but it is in there.) > > consider:

[go-nuts] Re: url.parse issue if the first character of a url is a number

2019-02-12 Thread jake6502
I can not speak directly to Go's version, but according to the IETF standards, a domain name can not start with a digit. So they are in fact malformed. On Sunday, February 10, 2019 at 9:23:54 PM UTC-5, Nathan Xu wrote: > > What I said is the url content without http/https . > > On Sunday,

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

2019-02-02 Thread jake6502
Always a good read on why that is still a problem: Benign Data Races: What Could Possibly Go Wrong? It is not specific to go, but mostly applies to any language, and is stuff all developers should

[go-nuts] Re: [ANN] goey - Declarative, cross-platform GUIs

2019-01-29 Thread jake6502
This looks quite interesting for the types of simple apps I'm building right now. However, I have discovered a couple of bugs. I don't see any way to report them on bitbucket. Are you taking bug reports, and if so, what is the best way to communicate them? Are you taking outside pull requests

[go-nuts] Re: What exactly is a method set?

2019-01-20 Thread jake6502
On Sunday, January 20, 2019 at 7:56:39 AM UTC-5, 伊藤和也 wrote: > > Yes I did. Can I say a method set is the one which associates an interface > with methods? > Almost. The method set *of an interface* is the set of methods in the interface. But other types, aside from interfaces, also have

Re: [go-nuts] Re: How to make the first character in a string lowercase?

2019-01-07 Thread jake6502
I believe he is demostrating an optimization for strings that are already in the correct form. On Monday, January 7, 2019 at 1:45:50 PM UTC-5, robert engels wrote: > > Huh? Isn’t your code calling the exact same method ? > > On Jan 7, 2019, at 12:22 PM, peterGo > > wrote: > > Nikolai, > > "What

[go-nuts] Re: C++ 11 to Golang convertor

2019-01-04 Thread jake6502
On Thursday, January 3, 2019 at 5:46:39 PM UTC-5, Eric Raymond wrote: > > On Thursday, January 3, 2019 at 12:11:06 PM UTC-5, Jake Montgomery wrote: >> >> I would note that any tool that ports from C++, or even C, to Go is going >> to produce ugly, unmaintainable, and non-idiomatic code, at best.

[go-nuts] Re: C++ 11 to Golang convertor

2019-01-03 Thread jake6502
There are so, so many ways to go about porting functionality from one language to another. I hope you have seriously considered why you want to make such a port. The answer to that will likely, in part, drive your strategy. In addition the nature and size of the code base, and your timeline,

[go-nuts] Re: What are the reasonable reasons to use pointers?

2019-01-01 Thread jake6502
What Cris said is one reason. That is, if you need the function being called to be able to change the value, then use a pointer. If you pass a value instead of a pointer, then changes made by the function being called are not visible to the caller. (The situation is more complicated, but that

[go-nuts] Re: Why can't I see the whole stack trace of goroutine

2018-11-08 Thread jake6502
I would point out that this *is *the whole stack trace *of the goroutine*. In fact, the actual stack trace is just the first line, since the goroutine in question is only one function deep. If you are breaking into your program after the leaking has started, then the function that created the

Re: [go-nuts] Correct way to solve slice of interface type problem

2018-10-31 Thread jake6502
It is highly likely that when go2 comes out, with generics, it will be trivial to write a ToInterfaceSlice() function that takes a slice of any type T and returns a []interface{}. On Tuesday, October 30, 2018 at 8:35:39 PM UTC-4, Justin Israel wrote: > > > > On Wed, Oct 31, 2018 at 1:32 PM

Re: [go-nuts] interface array and ... operator

2018-10-25 Thread jake6502
In my defense, neither A() nor B() complies in the actual example given. If you comment out A() you will see that B() then fails to compile. If B() is fixed by replacing "i = append(i, s)" with "i = append(i, sa)", then it succeeds. I believe that is due to the clause I referenced in my

Re: [go-nuts] interface array and ... operator

2018-10-25 Thread jake6502
Oops. Please ignore my entire post. Misunderstood completely. On Wednesday, October 24, 2018 at 11:55:18 AM UTC-4, Jake Montgomery wrote: > > That is correct. The relevant part of > https://golang.org/ref/spec#Passing_arguments_to_..._parameters is where > it says: " respective parameter

Re: [go-nuts] interface array and ... operator

2018-10-25 Thread jake6502
Yes. I was completely mistaken in my post. Apologies. On Wednesday, October 24, 2018 at 12:14:36 PM UTC-4, robert engels wrote: > > I quote > > So in the OP's example https://play.golang.org/p/59bpr8TCIge, the > function A() is assigning a []string to the variadic ...[]interface{}. > Since

Re: [go-nuts] interface array and ... operator

2018-10-24 Thread jake6502
That is correct. The relevant part of https://golang.org/ref/spec#Passing_arguments_to_..._parameters is where it says: " respective parameter passing rules apply". This links to

[go-nuts] Re: array indexed by derived type?

2018-10-07 Thread jake6502
I'm gonna say no. On Saturday, October 6, 2018 at 5:07:33 PM UTC-4, Steve Roth wrote: > > Is there a way to declare an array (or slice) that is indexed by a type > derived from int, rather than indexed by int? My intent is to have the > compiler complain if I index the array/slice with a

[go-nuts] Re: What can i transport in a channel?

2018-10-02 Thread jake6502
To expand on what Tamás said ... There is really nothing that is not safe to transport in a channel. But there are some considerations. For example if you transport an *http.**Response* then you will be making a copy on the way in and out of the channel. So that *may *not be safe, but it has

[go-nuts] Re: Generics - Why contracts?

2018-09-12 Thread jake6502
Some of the reasons for contracts have been covered by others in this thread already. But somehow one of the biggest has not. Contracts make it possible to change the implementation of a generic function in a published package. Without a contract it would be super easy for a seemingly simple

Re: [go-nuts] A thought on contracts

2018-09-10 Thread jake6502
Personally, I'm not afraid of writing contracts manually. I suspect that in the vast majority of the cases the contract will be clear and pretty trivial. In fact, I think it could be a productive part of the design process to consider what your generic function minimally needs and write the

[go-nuts] Re: Go’s runtime vs virtual machine

2018-09-04 Thread jake6502
There are a lot of differences, and for the answer to be complete, you would need to specify which language you wanted to compare it to. But on a really simple level, thwd's answer is more or less correct. A VM language is usually compiled into an instruction set for that VM. The VM then

[go-nuts] Re: Does fmt.Print* automatically render an error string in as struct (play link)

2018-08-29 Thread jake6502
> > I can't find anything saying as such From https://golang.org/pkg/fmt/ : "*4. If an operand implements the error interface, the Error method will be invoked to convert the object to a string, which will then be formatted as required by the verb (if any).*" As mentioned in another

[go-nuts] Re: Regarding string immutablity

2018-08-28 Thread jake6502
I think Jan answered the question asked. But, do you have some specific concern that prompted the question? Is it about security, or memory usage, or just curiosity? On Tuesday, August 28, 2018 at 10:55:27 AM UTC-4, Jay Sharma wrote: > > Hi All, > > I went through documentation and many post.

[go-nuts] Re: What is the proper way to delete a key which holding a pointer in a map

2018-08-27 Thread jake6502
Just to be clear, the memory used by the values *are *freed. In your example, those are the Person structs. It is only the internal memory used by the map that is not freed. See https://play.golang.org/p/fWOIbvjFjyB. In that test, the "internal" memory that is not freed is about 14 bytes per

Re: [go-nuts] Re: Ioctl Syscall with go and c

2018-08-26 Thread jake6502
I was aware that your parameters would not fit the Ioctl functions. As Ian pointed out, you would need to use *golang.org/x/sys/unix/Syscall() *and friends. On Sunday, August 26, 2018 at 10:00:11 AM UTC-4, sbez...@cisco.com wrote: > > Hi Jake, > > > > Ioctl implementation in unix package

[go-nuts] Re: Ioctl Syscall with go and c

2018-08-24 Thread jake6502
Probably unrelated to your problem, but IIUC, the syscall package is "deprecated", or "frozen". According to the syscall documentation : > *This package is locked down. Code outside the standard Go repository > should be migrated to use the corresponding

Re: [go-nuts] Re: Ioctl Syscall with go and c

2018-08-23 Thread jake6502
First off, I don't know how you are posting your code samples, but they are unreadable in my Firefox and Chrome on windows. Second, I would point out that the system you use for converting a "string" to the buffer will fail if there are any non-ascii characters. Third, OT, but I wonder why

[go-nuts] Re: Decoding the buffer to a struct sent from C program

2018-08-16 Thread jake6502
Perhaps someone can spot the error just by looking at your code. But a couple of tips that will help others help you. 1. Specify what exactly the "failure" is. What output do you get? 2. Include the log output for a sample run. 3. Print, and include a sample value of "data" (the binary data

[go-nuts] Re: Go modules and semver question

2018-08-15 Thread jake6502
The initial premise was that the API and "Behavior" have not changed. What this means for the literal API is pretty clear - that public function signatures and such are unchanged. "Behavior" is a bit more tricky and subjective. If you define "behavior" is the strictest possible sense, then

[go-nuts] Re: `go test -c` skips init from main while `go test` doesn't

2018-08-14 Thread jake6502
I am unable to reproduce using a small test app on either Windows or Ubuntu, using go 1.10.3. In all cases the init() function in main is run when the test binary is run. Perhaps you could provide a minimal reproducible example? On Monday, August 13, 2018 at 8:21:30 PM UTC-4, Gert wrote: > >

[go-nuts] Re: Examples testing with two newline, but only one newline

2018-08-13 Thread jake6502
Looks like a bug to me. I would suggest you open an issue. It is not clear to me what the intended behavior is. It is documented that examples strip some white space when comparing output. So it may be intentional that multiple white space lines are removed from the expected output. In that

[go-nuts] Re: How should I avoid - literal copies lock value from

2018-08-11 Thread jake6502
I don't see anything fundamentally wrong with using a *sync.Mutex as long as users always use New(). It allows Set to be passed by value, which is nice. But if you keep the mutex as a non pointer, then you probably want to pass a slice of set pointers: func (set *Set) Diff(sets []*Set) *Set

[go-nuts] Re: What is rationale behind slices cannot be compared to each other with == ?

2018-08-02 Thread jake6502
A previous discussion of this was quite long (89 posts) - maybe start there: https://groups.google.com/d/msg/golang-nuts/ajXzEM6lqJI/wbTPh2TmAwAJ On Thursday, August 2, 2018 at 1:21:15 PM UTC-4, Andrey Tcherepanov wrote: > > The following code does not compile. What was *rationale* behind slices

Re: [go-nuts] stdatomic.h, cgo, and sync/atomic

2018-08-02 Thread jake6502
On Wednesday, August 1, 2018 at 10:17:38 AM UTC-4, Ian Lance Taylor wrote: > > [...] > That said, the exact semantics of the sync/atomic operations are not > written down (that is https://golang.org/issue/5045). > I really love go, but this is one thing that has annoyed me for years. This

[go-nuts] Re: Counting semaphore vs Workerpool

2018-05-26 Thread jake6502
So, it looks to me like 1 million URLS will spin up 1 million goroutines. That seems unnecessary, and likely to be a problem. I usually default to the simplest model, unless there is a reason to do otherwise. IMHO, here that would be to spin up as many goroutines as you want to be working at

[go-nuts] Re: Freeing memory of a cgo library

2018-05-26 Thread jake6502
FYI, the standard way around this is to expose a "free" method from your DLL for memory allocated by the DLL. The other way is to require that users of the DLL supply the memory in advance to functions needing it. These two methods are the ones used by the Windows libraries themselves. Pretty

[go-nuts] Re: Freeing memory of a cgo library

2018-05-25 Thread jake6502
Looks like you are on windows. I have worked a lot with windows, C/C++ and go, but never actually built a go dll. But, since no one else has picked this up, maybe I can help. 1. I'm not sure what "the cgo" library means here? Do you have this: cpp<->go(dll)<->c(cgo)? Or something else. 2.

[go-nuts] Re: An issue with the select statement.

2018-05-11 Thread jake6502
As others on this thread have pointed out, this use case does not actually require select where the cases are checked in order. However, for completeness, if you need to check two channels, and they must be checked in order, then use two select statements with defaults: for { select {

[go-nuts] Re: On Accepting Interfaces and Structs

2018-04-26 Thread jake6502
The example gives me a better understanding of what you are doing, though still not much understanding as to *why *you are doing it this way. Usually, if I feel that code has a "smell" in Go, there is a way to rethink the basic design resulting more "natural" code. But without a full

[go-nuts] Re: On Accepting Interfaces and Structs

2018-04-23 Thread jake6502
My gut feeling is that there is an elegant way to achieve what you want. Unfortunately, I am having trouble following the code you are describing, and more importantly, what you are actually trying to accomplish. Perhaps it is my failing. If you would post a more complete example, showing the

Re: [go-nuts] Extension for type assertion of interface array

2018-04-19 Thread jake6502
Yes, to use the functions above you will need to copy the slices of landSpaceto slices of the respective interface types. But I you do not need to do any type assertions. Like this: https://play.golang.org/p/eFTUqpImyPc package main import ( "fmt" ) type landSpace struct{} func

Re: [go-nuts] sync.Cond implementation

2018-04-16 Thread jake6502
On Monday, April 16, 2018 at 7:08:27 AM UTC-4, Jesper Louis Andersen wrote: > > On Sat, Apr 14, 2018 at 7:02 PM Penguin Enormous > wrote: > >> But looking at your answer, I see that you may imply certain race >> conditions are allowed. Could you explain a bit more on that?

[go-nuts] Re: Scheduler discrepancy between Linux and OS X with Gosched()

2018-04-03 Thread jake6502
For what it is worth, when I run your new code (without channels) on windows it takes consistently 1 second. On Linux it takes variably between 400ms and 1.5 seconds. Both running go 1.10. But, on my systems, this seems to be actually measuring time.Sleep(). Removing the call to spin() and the

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

2018-03-24 Thread jake6502
There may not be any guarantee that the channel will always be full, but in practice your code always produces 100 results for me. Both in the playground , and on my machine (go version go1.10 windows/amd64). With or without the Sleep commented out. Am I

[go-nuts] Re: Long running task in select case

2018-03-17 Thread jake6502
On Saturday, March 17, 2018 at 10:37:48 AM UTC-4, matthe...@gmail.com wrote: > > I think the second example alternative given (playground link above) has a >> data race? > > > I’m not surprised that the race detector sees something (a read can happen > during a write of the checked bool) but I

[go-nuts] Re: confusing a lock demo about https://golang.org/ref/mem#tmp_8

2018-03-13 Thread jake6502
I would like to point out that the example code you refer to is meant to illustrate a specific behavior of locks. It is *not* necessarily intended to be an example of good style. As a "new gopher" I would avoid this idiom. If you did use this, some significant commenting would be needed.

[go-nuts] Re: Struct confusion... what am I missing?

2018-03-12 Thread jake6502
Ok, so I looked at the https://github.com/tidwall/gjson/blob/master/gjson.go code, and see that the jsonvals slice is a slice of: type Result struct { // Type is the json type Type Type // Raw is the raw json Raw string // Str is the json string Str string // Num is the json number Num

[go-nuts] Re: Struct confusion... what am I missing?

2018-03-12 Thread jake6502
I have not run this. But based on your comments, jsonvals is a slice. So you would presumably need to check the length then access a specific item in the slice like this: fmt.Printf("\n%+v\n", jsonvals[0].ID) Hope that helps. On Monday, March 12, 2018 at 12:01:33 PM UTC-4,

[go-nuts] Re: What major API change really is?

2018-03-10 Thread jake6502
This is one of those topics on which everyone has and opinion and no two people will agree 100%. I will say that "Go by your gut" is probably bad general advice. It works well for folks that have a lot of experience, and have done significant reading and research on the topic. But "going with

[go-nuts] Re: Experience report on coming to Go from a C perspective

2018-02-22 Thread jake6502
Have you considered using the new type alias feature introduced in 1.9? Line so: https://play.golang.org/p/6HK8qcuh9UU This would allow you to change the type of the map in a singe place (the type alias) and all the *{}* or *make *would adapt appropriately. Disclaimer: I am not espousing this

[go-nuts] Re: printing a struct fields that implements an error interface

2018-02-18 Thread jake6502
There may be another way, but this is one way to print the struct fields: https://play.golang.org/p/sGZMBGG7r79 See line 17. On Sunday, February 18, 2018 at 8:57:02 AM UTC-5, Diego Medina wrote: > > using %#v > > as in > > https://play.golang.org/p/VVqUVsfzx6e > > > > log.Printf("Hello,

[go-nuts] Re: making common declarations for several packages?

2018-02-03 Thread jake6502
Referencing a type from another package must specify what package it comes from. Try: var a *common.Any Also, I would avoid using the term "alias" here. Type aliasing in go is totally different from defining a new type, which is what you do here. Type aliasing takes the form: type T1 = T2

[go-nuts] Re: glog + vendor = "flag redefined: log_dir"?

2018-01-30 Thread jake6502
Ok, maybe I'm a bit off topic. But this also points out why I firmly believe that libraries should not add things to the default flag set in an init function. This is just one of many cases where that can cause problems. @Library developers - please, please consider supplying the user with an

[go-nuts] Re: Async process state snapshotting in Golang

2018-01-27 Thread jake6502
A couple of comments. This is probably obvious, but I wanted to point out that matthe...'s code would require *all *access to the map to be synchronized using the mutex. It's a simple and effective solution. One downside to his code is that it holds the lock for the duration of the Copy().

[go-nuts] Re: "Try Go" in golang.org stopped working properly?

2018-01-27 Thread jake6502
I see the same thing. Changing even one character fixes the problem. Even just adding white space to the code. If I copy the example from https://golang.org/ to the playground exactly ( https://play.golang.org/p/-MKUWeDBml7 ) it also prints nothing. Strange On Saturday, January 27, 2018 at

Re: [go-nuts] Using reflect to call functions on struct members

2018-01-19 Thread jake6502
I think this 40 second snippet of a talk by Rob Pike is apropos. It is not specific to your case, but speaks of reflection in general. On Thursday, January 18, 2018 at 5:20:26 PM UTC-5, Boone Severson wrote: > > Ok, asked and

[go-nuts] Re: question about golang concurrency

2018-01-08 Thread jake6502
Your use of the sync.Mutex seems sound. At first glance, I see no concurrency problems. I would suggest running the program with the -race flag. If you make memoryCache a package, then perhaps a concurrent test that can be run with -race would also be good. In that case you may also want to

Re: [go-nuts] How to get nice html from godoc?

2017-12-17 Thread jake6502
Thanks Justin I will give it a try. (It certainly would be nice if "*godoc -html"* could be useful without having to modify the html.) On Saturday, December 16, 2017 at 6:41:07 PM UTC-5, Justin Israel wrote: > > > > On Sun, Dec 17, 2017 at 5:47 AM wrote: > >> I suspected

Re: [go-nuts] How to get nice html from godoc?

2017-12-16 Thread jake6502
I suspected it was something like that. I can muddle through, but HTML, and all that is not really my wheelhouse. Can you give me any more details? - Where can I find the correct "bundled css/js" files? - Where do I put them relative to the HTML file? - Do I need to modify the HTML

[go-nuts] Re: Use golang to call the win API

2017-12-15 Thread jake6502
I have not called a Windows API from go before, so there may be other problems with your code. But looking at WlanEnumInterfaces documentation the last parameter is *not *a pointer to a pointer to a

[go-nuts] Re: go test/flag.NewFlagSet bug?

2017-12-13 Thread jake6502
I'm not sure how you expect the *nfs=true* case to work. The "-data=x" flag will be passed to test binary, as described in the documentation. But the test binary is not just your test code, it also contains the testing framework, which must run some variant of *flag.Parse()* in order to parse

Re: [go-nuts] Does uintptr count as a refence?

2017-11-26 Thread jake6502
Thanks. That is clear: *A uintptr is an integer, not a reference. Converting a Pointer to a uintptr creates an integer value with no pointer semantics. Even if a uintptr holds the address of some object, the garbage collector will not update that uintptr's value if the object moves, nor will

  1   2   >