[go-nuts] Re: I am confused.

2018-05-23 Thread matthewjuran
The go command prompt program (“go help”) will run the compiler, a separate program, when certain commands are used (like “go build”). The compile process creates a file that is the program you wrote if no errors are found, and you can then run this program file to do the work you coded. An

[go-nuts] Re: From PHP to Go, here my first side project. What do you think?

2018-05-22 Thread matthewjuran
Hello, here’s a code review. Thanks for sharing here. These are my unfiltered opinions that may be wrong, and I hope they are useful for you. Have you considered including an open source license like BSD? There’s a base GitHub license applied now. func CreateRelative( path string,

[go-nuts] Re: I am confused.

2018-05-21 Thread matthewjuran
Emacs (https://www.gnu.org/software/emacs/), Notepad++ (https://notepad-plus-plus.org/), and Vim (https://www.vim.org/) are code editors that work on Windows. I use Vim on macOS. Emacs and Vim will take longer to learn than Notepad++. These editors let you open and modify code files (right

Re: [go-nuts] Re: Validation checks in Go

2018-05-19 Thread matthewjuran
An example is nil map access or concurrent map access both cause panics in the runtime (https://github.com/golang/go/blob/release-branch.go1.10/src/runtime/hashmap.go#L357). A useful thing panic without recover does is print the stack trace. Matt On Saturday, May 19, 2018 at 11:57:33 AM

[go-nuts] Re: [ANN] Pion-TURN, a TURN server designed with ease of use and extensibility in mind

2018-05-19 Thread matthewjuran
Thanks for the kind reply. Should I change this name, but still keep things like the realm/socket as > members still? I think of turn.Server as the global singleton that handles > all traffic (UDP or TCP) An interface is used to allow varying types to have the same logic applied. In this

[go-nuts] Re: Load balancing with error feedback capabilities

2018-05-18 Thread matthewjuran
By embedding I meant this: type ServiceQProperties struct { ... sync.Mutex } which allows you to call p.Lock() instead of p.REMutex.Lock(). It’s just a personal preference that I was happy about when I learned about it. One thought here is you could make it a *sync.Mutex and not use a

[go-nuts] Re: Load balancing with error feedback capabilities

2018-05-18 Thread matthewjuran
Hi Ankit, thanks for the Apache license and for sharing here. Here’s a code review. These are my unfiltered opinions and I hope that they are useful. Without looking at any code yet, the packages might not be idiomatic. Packages should contain specific behavior that can be decoupled from the

Re: [go-nuts] Re: Go license and fitness for purpose

2018-05-17 Thread matthewjuran
Thanks for responding Michael. "decorative item not to be used off-road, in uneven terrain, or relied upon > as protection in case of vehicle roll." The sticker I’ve been looking at says something like “modifying or attaching anything to this ROPS will compromise the structure and may cause

Re: [go-nuts] Re: Go license and fitness for purpose

2018-05-17 Thread matthewjuran
I was thinking something like writing an undocumented “Happy New Year!” to standard out at the start of the year. An obvious but undocumented ‘rm -rf /‘ attempt was mentioned above. My first program was a practical joke. On the calculator command line I said “press enter” then put the program

[go-nuts] Re: [ANN] Dependencies for dummies

2018-05-16 Thread matthewjuran
You answered it, thanks. Matt On Wednesday, May 16, 2018 at 4:14:35 AM UTC-5, Gerardo Oscar JT wrote: > > Hello Matt, > > Having dependencies inside the project is the easiest way to make > reproducible builds (without having infrastructure for mirrors) and makes > your organization more

[go-nuts] Re: Validation checks in Go

2018-05-16 Thread matthewjuran
I may have misunderstood the question. I follow the idea of panic when the program is in an invalid state. If Divide can receive any input then this is probably a better API: func Divide(a, b float64) (float64, error) { where you would return an ErrDivideByZero made with errors.New as a global

[go-nuts] Re: Go license and fitness for purpose

2018-05-16 Thread matthewjuran
> > It is not necessary to state up front that you are not willful and > malicious, or careless or negligent. Society expects that from you anyway. I think practical jokes should be allowed under the GPL, BSD, and similar licenses. If you really have legal concerns you should talk to a

Re: [go-nuts] Go license and fitness for purpose

2018-05-15 Thread matthewjuran
I get that we have to work with the legal system details and that they may cause strange terms. Thanks for sharing some of those US details. Isn’t there responsibility in putting tools out there publicly for anybody to use? Perhaps public distribution under the terms “don’t use this” is

[go-nuts] Re: dynamic programming or something else

2018-05-15 Thread matthewjuran
Hi Alex, You may want to have logic tests in place to be sure your improvements are correct. Capturing the complete call graph and CPU/memory usage using pprof may help reveal improvements. The visualization output has options you might want to adjust. Inspecting the assembly output is

[go-nuts] Re: [ANN] Pion-TURN, a TURN server designed with ease of use and extensibility in mind

2018-05-15 Thread matthewjuran
My mistake, I see that there is more library code at https://github.com/pions/pkg Thanks, Matt On Tuesday, May 15, 2018 at 9:46:46 AM UTC-5, matthe...@gmail.com wrote: > > Hello, thanks for sharing here and thanks for the MIT license. Here’s a > code review. > > These are my unfiltered

[go-nuts] Re: [ANN] Pion-TURN, a TURN server designed with ease of use and extensibility in mind

2018-05-15 Thread matthewjuran
Hello, thanks for sharing here and thanks for the MIT license. Here’s a code review. These are my unfiltered opinions. You may not agree with some or any of them, and some or all of them might not be reasonable to implement. My goal is to build an ideal way to write Go code by doing code

[go-nuts] Re: [ANN] Dependencies for dummies

2018-05-15 Thread matthewjuran
Hello, I haven’t seen this pattern: src/vendor/github.com/fulldump/goconfig I’ve put vendored dependencies in the project: src/github.com/my/project/vendor/github.com/fulldump/goconfig Why are you doing it this way? Have you tried vgo? https://github.com/golang/vgo Matt On Sunday, May 13,

Re: [go-nuts] Go license and fitness for purpose

2018-05-15 Thread matthewjuran
I don’t think I’m suggesting to not disclaim liability. I’m suggesting to claim that I didn’t hide anything to make a use break on purpose. It does add liability, but this is liability that is completely in the author’s control unlike regular bugs or misuse that disclaiming other liability

[go-nuts] Re: Validation checks in Go

2018-05-15 Thread matthewjuran
What I’ve seen in the standard library was no named asserts like this, just if checks with panics. The panic functionality does what you’ve described. Personally I prefer the look of if+panic instead of another function for this. Matt On Monday, May 14, 2018 at 7:38:32 PM UTC-5, Tristan

Re: [go-nuts] Go license and fitness for purpose

2018-05-14 Thread matthewjuran
> > Legalese that OP tried to ridicule (imo) says otherwise. They can be sued > but they can not lose, even if they intentionally would put a `rm -rf /` > in > the code. I mentioned email addresses being stolen, but I’m more concerned about things like somebody thinking they can use GCC

[go-nuts] Re: RFC - Review request for a project done in Golang

2018-05-14 Thread matthewjuran
They might have been looking for something like this: github.com/psankar/network-monitor package monitor code files cmd/ minion/ package main code files server/ package main code files In a code review I would mention the use of packages as not

Re: [go-nuts] Go license and fitness for purpose

2018-05-14 Thread matthewjuran
> > I suspect you are worrying too much given both the long history of > open source software and the large number of > groups/organizations/companies that rely on it. I was reading about the ILOVEYOU Windows virus and recall hearing about it at the time. In that case the way Windows worked

Re: [go-nuts] Go license and fitness for purpose

2018-05-13 Thread matthewjuran
> > Why would you assume more liability than necessary? My thought is the authors want to gain serious users to increase feedback quality and improve the developer market. I thought this was why Google let Go be open source besides attracting academic uses. And as an open source developer

[go-nuts] Go license and fitness for purpose

2018-05-13 Thread matthewjuran
Hello, The gccgo license has this section: THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS > "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT > LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR > A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO

Re: [go-nuts] Re: Go could really use a while statement

2018-05-12 Thread matthewjuran
That would be funny to me. I have been guilty of being disrespectful to people in person about their C code choices, but I thought it was justified because I was hoping to get good technical reasons in response and didn’t intend anything personally targeted. ‘Crusade’ was a word I’d use for

[go-nuts] Re: Go could really use a while statement

2018-05-12 Thread matthewjuran
> > It's certainly diverged from my original post, which is why I'm staying > quiet. I was hoping to get back on track after you sent this so you’d want to participate. goto is another way to do loops in Go: https://play.golang.org/p/0chmb5DeOym Matt On Wednesday, May 9, 2018 at 4:26:44 PM

[go-nuts] Re: Go could really use a while statement

2018-05-10 Thread matthewjuran
The lack of citations makes the content untrustworthy to me, but this English Wikipedia article on loops claims some history starting with the do loop in FORTRAN (1957): https://en.wikipedia.org/wiki/For_loop This article says the three part for loop was introduced in C/C++ (1972), and

[go-nuts] Re: Go could really use a while statement

2018-05-09 Thread matthewjuran
I’m not sure if C has been directly mentioned. I started with C so iteration is just a nice shortcut to me. Assuming you’ve always had collection iteration available an explanation is the for loop can make the useful pattern of indexing into an array up to the length of the array using an

Re: [go-nuts] Cyclic types

2018-05-09 Thread matthewjuran
More accurately: const size = 10 type T struct { a [size]int // many other fields and comments b [size*unsafe.Sizeof(int(0))]int } Matt On Wednesday, May 9, 2018 at 1:56:53 PM UTC-5, matthe...@gmail.com wrote: > > type T struct { > a [10]int > b [len(T{}.a)]int > } > >

Re: [go-nuts] Cyclic types

2018-05-09 Thread matthewjuran
type T struct { a [10]int b [len(T{}.a)]int } could appear about as maintainably like this: const size = 10 type T struct { a [size]int // many other fields and comments b [size]int } This case doesn’t justify more complexity to me. Matt On Wednesday, May 9, 2018 at

Re: [go-nuts] Re: I don't know about callbacks in Golang

2018-05-07 Thread matthewjuran
The first approach with a func argument to a func can be synchronous (which is what I was thinking at the time) or it could be asynchronous by using the go keyword on the callback. Matt On Monday, May 7, 2018 at 11:48:20 AM UTC-5, florent giraud wrote: > > ok matthew so what you propose is

[go-nuts] Re: I don't know about callbacks in Golang

2018-05-07 Thread matthewjuran
Corrected mistake: func SignalsCallback(arg1 int, arg2 string, callback chan<- struct{}) SignalsCallback will only write to callback, not read. Matt On Monday, May 7, 2018 at 10:08:27 AM UTC-5, matthe...@gmail.com wrote: > > Callbacks in Go can be done with a func argument to a func, or a

[go-nuts] Re: I don't know about callbacks in Golang

2018-05-07 Thread matthewjuran
Callbacks in Go can be done with a func argument to a func, or a similar effect can be made with channels by triggering a callback action by waiting on a blocking channel in the application. This Wikipedia article describes the pattern:

Re: [go-nuts] [ANN] GoKi Trees and GoGi GUI

2018-05-07 Thread matthewjuran
> > I’m pretty sure you can just type "go get …” and it finds all the > dependencies automatically, and they are likely to change over time, so I’m > not sure it is conventional to list them? You may want to vendor them (https://golang.org/cmd/go/#hdr-Vendor_Directories) so if they ever go

[go-nuts] Re: fallthrough for select

2018-05-07 Thread matthewjuran
The proposal I opened for this was declined recently: https://github.com/golang/go/issues/23196 Matt On Saturday, May 5, 2018 at 11:35:08 PM UTC-5, Simon Chevrier wrote: > > Hi, I know this is kind of old and I'm not sure anyone will answer, but > even after the previous discussion I feel like

Re: [go-nuts] Re: [ANN] GoKi Trees and GoGi GUI

2018-05-05 Thread matthewjuran
In a generic container I would expect to see items typed as interface{} and the behavior defined on a slice of interface{} or struct with private slice of interface{} field. >From the godoc it looks like type Node implements type Ki, and there’s no other type that implements Ki. I don’t

Re: [go-nuts] Implementing method overloading using first class functions

2018-05-05 Thread matthewjuran
> > I sorta only vaguely understand what you mean about being 'too big'. I’m being vague and I haven’t read this thread in detail besides seeing type B in the first email. I plan to read it in detail and send another response. I’m speaking from the idea behind a version of this story:

[go-nuts] Re: Is there any #blog which writes about how to succeed as a fresher Go programmer?

2018-05-04 Thread matthewjuran
I’m assuming you’re asking how to make a career around Go. For a career you might be best served by blogs about general software development or software engineering. Others here may be able to point you in the right direction for blogs. I’m not sure if “software” is still the best word for it.

Re: [go-nuts] Implementing method overloading using first class functions

2018-05-04 Thread matthewjuran
With byte slices you’ll need to pay attention to reallocation of the backing array as a possible source of performance problems (https://blog.golang.org/go-slices-usage-and-internals). I can see clearly how freakin complex code gets when you try to do generics > and polymorphism. I think

[go-nuts] Re: [ANN] GoKi Trees and GoGi GUI

2018-05-04 Thread matthewjuran
Hi Randy, here’s a code review. Thanks for the BSD license. I prefer the look of a minimized import path, I would have put the title library at the top level (github.com/goki/ki). To me the README doesn’t balance text and code examples well enough, I’d like to see more example uses and less

[go-nuts] Re: Go could really use a while statement

2018-05-03 Thread matthewjuran
> > These threads are akin to bike shedding thus a waste of time. In storytelling relief is part of good tragedy. I consider the overloading of for to be a plus because for, while, do-while are just loops with conditions. Maybe ‘loop’ is a more Go-like keyword. loop i, e := range c { Matt

[go-nuts] Re: Looking for go programmers for game company

2018-05-01 Thread matthewjuran
I may be interested. Can you share background about your company here? Thanks, Matt On Saturday, April 28, 2018 at 10:52:01 PM UTC-5, smga...@gmail.com wrote: > > Hey gophers. I have a multi platform game company that is also integrating > blockchain technology as well as crypto currency. I am

[go-nuts] Re: Beginner question about interface

2018-04-28 Thread matthewjuran
grep -r ") Read(" . If you have grep this works ok (-r to recursively look in directories) if you want to isolate one method. Matt On Saturday, April 28, 2018 at 12:06:07 AM UTC-5, k1at...@gmail.com wrote: > > Hi > > How can i get a list of types which implement a particular interface ? ( >

[go-nuts] Re: Using variadic function / context in an interface?

2018-04-27 Thread matthewjuran
Each call to Run could check if the struct has been initialized and initialize it if not. An approach is a function field could be swapped out after initialization. Matt On Thursday, April 26, 2018 at 11:55:07 AM UTC-5, Nimrod Shneor wrote: > > Hey everyone, > I've encountered a design issue -

[go-nuts] Article: Go for art

2018-04-26 Thread matthewjuran
Hello, Here’s an article I’ve written about Go: https://github.com/pciet/goforart “Go for art. An article about the Go programming language and greater professional software community.” I wrote this today but there is a lot of research built into it. There is discussion about religion, and

Re: [go-nuts] [ANN] oksvg and rasterx; SVG 2.0 path compliant renderer and rasterizer

2018-04-25 Thread matthewjuran
> > So it sounds like the AGPL is a good license to choose if you want to keep > your code from being used by big companies… ;-) If your project is secret software with a public network interface then don’t apply the AGPL to it. That’s not the only kind of software used at big companies.

Re: [go-nuts] Type func binding and interfaces

2018-04-25 Thread matthewjuran
> > Any code that keeps data aligned to memory page and disk page sizes is > automatically significantly faster, because misalignment automatically > doubles the amount of memory that has to be accessed to satisfy a request. > This is why Binary Heaps are way slower than B-heaps. My opinion

Re: [go-nuts] Type func binding and interfaces

2018-04-25 Thread matthewjuran
> > I worked for a little while on the C++ server application for the Steem > network node, and I was intending to remove a whole swathe of code relating > to protocol changes at various hard forks. The number of times I ran across > poorly ordered if/then (not even using switch!) that would

Re: [go-nuts] [ANN] oksvg and rasterx; SVG 2.0 path compliant renderer and rasterizer

2018-04-24 Thread matthewjuran
I’m curious if some companies juggle the GPL. I guess if the app is used internally only then there’s no problem with accidentally requiring a proprietary program to be released as source code to the world. I’d have thought the case would be the same with the AGPL. Do people count as

Re: [go-nuts] Type func binding and interfaces

2018-04-24 Thread matthewjuran
> > I'd suggest starting with the basic algorithm without any abstraction > (just hard-code in the type you want to store), then benchmark/tweak > the algorithm, and only then try to make it general. This is my conclusion too. Abstracting the code is a lot of churn if we’re not sure

[go-nuts] Re: About start with Capital letter as public API and golang's no generic

2018-04-24 Thread matthewjuran
Here's the generics discussion: https://github.com/golang/go/issues/15292 Matt On Tuesday, April 24, 2018 at 9:06:10 AM UTC-5, Deven You wrote: > > I am a newbie on Golang and find go syntax is pretty concise and I like it. > > However, the syntax for public API seems a little trouble for me. >

Re: [go-nuts] [ANN] oksvg and rasterx; SVG 2.0 path compliant renderer and rasterizer

2018-04-24 Thread matthewjuran
> > On the other hand oksvg is completely de novo, so I can slap whatever > license I want on that package. I take it people here prefer the Go > license? Can anyone briefly describe the difference? I will definitely > change it if someone can give me a good reason. I just want to make it as

[go-nuts] Re: go lang best practices and git repo structure for newbies

2018-04-23 Thread matthewjuran
Hi Teja, I found Effective Go to be generally helpful: https://golang.org/doc/effective_go.html Here’s my best example: https://github.com/pciet/wichess My golang-nuts code review points: - don’t overuse interface (consider closures and function types/fields) - don’t overuse packages, make

[go-nuts] Re: Type func binding and interfaces

2018-04-23 Thread matthewjuran
Is the need for a memory efficient implementation backed by a performance profile? Matt On Monday, April 23, 2018 at 10:26:41 AM UTC-5, Louki Sumirniy wrote: > > First issue is that BAST does not use references. This is so that searches > proceed linearly through memory. Instead it uses a flat

[go-nuts] Re: Type func binding and interfaces

2018-04-23 Thread matthewjuran
> > But I don't want to tie my users down to integers and floats. What if they > want to sort strings? What if they want to sort complex numbers, matrixes, > or what have you? This is what the interface concept was made for. Why would the implementation of IsLeft be different if the BAST

[go-nuts] Re: Type func binding and interfaces

2018-04-23 Thread matthewjuran
This is a code smell for me: type BAST interface { AddRow() error IsLeft(interface{}, Cursor) bool IsRight(interface{}, Cursor) bool IsEqual(interface{}, Cursor) bool IsEmpty(Cursor) bool … Interfaces should be small. This looks like a class definition which isn’t a Go

[go-nuts] Re: Type func binding and interfaces

2018-04-22 Thread matthewjuran
Interface types are useful when the data structure is varied. Why not an interface containing these varying functions as methods instead of function types? Matt On Sunday, April 22, 2018 at 5:20:12 PM UTC-5, Louki Sumirniy wrote: > > I essentially am trying to find an effective method in Go,

[go-nuts] Re: Fancy Comments & Documentation

2018-04-19 Thread matthewjuran
gofmt and godoc remove choices that are fun, artistic, or tempting, but distracting. I think you'll be best served by Go without the box. Matt On Thursday, April 19, 2018 at 6:42:40 PM UTC-5, Chris FractalBach wrote: > > Test #1 > Source: > /* > +--+ > |

[go-nuts] Re: http "alt" attribute value for img tag?

2018-04-19 Thread matthewjuran
I would start by isolating the alt=“…” string with splits (https://golang.org/pkg/strings/#Split) then use Sscanf (https://golang.org/pkg/fmt/#Sscanf) to parse the number. There may be other approaches like regular expressions. Matt On Wednesday, April 18, 2018 at 9:52:28 PM UTC-5, l vic

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

2018-04-18 Thread matthewjuran
I think if you opened a proposal it would be merged into the generics discussion: https://github.com/golang/go/issues/15292 There may be other ways to write the program, can you provide a concrete example of where you’ve needed this? Matt On Wednesday, April 18, 2018 at 9:13:59 AM UTC-5,

Re: [go-nuts] Usage example inside a lib project

2018-04-18 Thread matthewjuran
An example directory works too and is pretty common. Matt On Wednesday, April 18, 2018 at 7:45:45 AM UTC-5, Federico Paolinelli wrote: > > Il giorno mercoledì 18 aprile 2018 08:41:30 UTC-4, Jan Mercl ha scritto: >> >> On Wed, Apr 18, 2018 at 2:35 PM Federico Paolinelli >>

[go-nuts] Re: code structure question

2018-04-18 Thread matthewjuran
Consider putting each ishell.Cmd in a separate file. Otherwise you can put them in a slice var so you don’t have to AddCmd each one explicitly. I’m not sure what defining a struct accomplishes, can you provide more detail? Matt On Tuesday, April 17, 2018 at 8:25:17 PM UTC-5, Keith Brown

[go-nuts] Re: Concurrent and blocking data

2018-04-09 Thread matthewjuran
> > 2. What does “concurrent and blocking” mean for a data structure? I think this means they’re asking about a form of concurrent programming where a caller will stop executing (block) while the data structure is accessed by a concurrent path. Non-blocking means the caller can continue

[go-nuts] Re: Interface Literals

2018-04-08 Thread matthewjuran
Here’s a way to do a similar thing now: https://play.golang.org/p/CtEYUo6MuqN func main() { x := []int{5, 1, 4, 2, 3} sort.Sort(ClosureSort(func() int { return (len(x)) }, func(i, j int) bool { return x[i] < x[j] }, func(i, j int) { x[i], x[j] = x[j], x[i] }))

[go-nuts] Re: Concurrent and blocking stack

2018-04-08 Thread matthewjuran
1. What are a stack and queue? 2. What does “concurrent and blocking” mean for a data structure? 3. What does accessing one var from concurrent goroutines look like? We can answer these for you if you don't know the answer. Matt On Sunday, April 8, 2018 at 12:37:26 AM UTC-5, Xen wrote: > > Hi

[go-nuts] Re: Language is a platform, which golang still does not pay attention to !!!

2018-04-06 Thread matthewjuran
> > But it solves the common problem in the IT industry. In my mind the major common problem is solved by computer hardware, not by a new programming language. Ordering machine instructions is doable for significant work. My take is we’re mostly worried about art here besides those doing big

[go-nuts] Re: Language is a platform, which golang still does not pay attention to !!!

2018-04-05 Thread matthewjuran
> > I think if it is not popular until 2020, it will never be popular. I’m not sure popularity is a shared goal in the community; the original goal is to solve problems at Google. Matt On Thursday, April 5, 2018 at 12:26:19 PM UTC-5, bingj...@gmail.com wrote: > > Almost 10 years golang

[go-nuts] Re: API fixes for sync.Mutex and friends?

2018-04-03 Thread matthewjuran
The pointer logic is a hard part of Go. I don’t know how much performance is gained by worrying about it, but I’ve learned to like having function/method call argument copies in some cases. I think becoming an expert on when to pick a pointer or not is a fundamental part of Go programming.

Re: [go-nuts] corrupt stack?

2018-04-03 Thread matthewjuran
Does the program use cgo? Matt On Monday, April 2, 2018 at 6:48:14 PM UTC-5, Erik Quanstrom wrote: > > after upgrading to 1.9 (50% reduction) and finding a data race we didn't > see in testing, > we're still hunting down about 1 crash per 67 million hours of runtime. > > needless to say, the

[go-nuts] Re: Is there any way to define a struct member to hold a generic type channel?

2018-03-26 Thread matthewjuran
With interface{} it has to be a type check at runtime: https://play.golang.org/p/t2jip9E__F1 Matt On Monday, March 26, 2018 at 12:34:34 PM UTC-5, 刘焱 wrote: > > 'chan interface {}' dosen't work. > > package main > > import "fmt" > > type ChannelWrapper struct { > Channel chan interface{} > }

[go-nuts] Re: [ANN] A golang source code query language

2018-03-24 Thread matthewjuran
Hi Forud, here’s a code review. Thanks for the MIT license. Seeing an empty struct type is a code smell to me, but I understand that this pattern may be required to be a database/sql driver. The unit tests seem good but I’d add an example or more in-depth overall test. In astdata/file.go

[go-nuts] Is there any way to define a struct member to hold a generic type channel?

2018-03-23 Thread matthewjuran
An empty interface var can hold any type, so you could have a chan interface{} then use an interface type assertion when you read a value. Matt -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving

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

2018-03-20 Thread matthewjuran
It’s channels either way: https://play.golang.org/p/OTNPsxiDSOp A difference is no access to context.Context.Err(), but in this example the error isn’t checked. My opinion is there’s no reason to bring in the whole context when all that’s needed is a cancel action. Also there’s an added

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

2018-03-19 Thread matthewjuran
Only a detail, but why not this instead as the API? func LongRunningTask(cancel <-chan struct{}, index int) (err error) { Matt On Monday, March 19, 2018 at 7:43:19 AM UTC-5, rog wrote: > > Why not something more like this? https://play.golang.org/p/3t4UtoFkoIt > > A lot of this comes down to

[go-nuts] Re: Flutter and golang

2018-03-19 Thread matthewjuran
> > I gave up matching the native OS. It's futile and just way too much work. Don't kill me but it's really down to your philosophy in the end. I’m asking because I’ve only done a web interface (where a cross-browser standardization library is useful for me), but I’ve used plenty of

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

2018-03-17 Thread matthewjuran
> > Only if it doesn't leave the shop like that, but with a P>0, it will. Before commit I usually go through many iterations, but what I shared was iteration one. I’m confident that iteration two wouldn’t have the data race in my case. I don’t think these playgrounds are a good place to

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

2018-03-17 Thread matthewjuran
Defending my reputation, I’m here for people making things, not for being an educator. Thinking quickly and making it work even with mistakes can be a valid approach sometimes. Matt On Saturday, March 17, 2018 at 2:05:55 PM UTC-5, Michael Jones wrote: > > these are excellent answers. > > i

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

2018-03-17 Thread matthewjuran
> > 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 don’t think this could actually cause problems because the var’s memory value will

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

2018-03-16 Thread matthewjuran
> > While this is running, your select won't be receiving on the quit > channel, even if it is non-nil. > If you want to be able to cancel it, you'll need to make the code in > the loop responsive to the quit channel > (for example, by using a select like you're using in f already). The

[go-nuts] Re: Would this race condition be considered a bug?

2018-03-16 Thread matthewjuran
sync.Mutex is an easy way to guard shared resources. I’ve heard hints to use channels instead of a mutex though. Matt On Thursday, March 15, 2018 at 9:11:49 PM UTC-5, Anmol Sethi wrote: > > https://play.golang.org/p/82Um1jSntBo > > Please run with the race detector to see the race. > > This

[go-nuts] Re: go build doesn't propagate options that disable optimizations

2018-03-15 Thread matthewjuran
This looks like it changed between 1.9.4 and 1.10. Here’s the documentation: https://github.com/golang/go/blob/release-branch.go1.10/src/cmd/go/internal/work/build.go#L113-L127 I guess the package patterns thing is new. Try this: go build -a -x -gcflags=“all=-N -l” Matt On Thursday, March

[go-nuts] Re: Why does crypto/rand expose Reader?

2018-03-15 Thread matthewjuran
We've been talking about this here: https://github.com/golang/go/issues/24160 and here: https://github.com/golang/go/issues/23267 Matt On Thursday, March 15, 2018 at 11:02:08 AM UTC-5, Volker Dobler wrote: > > Importing malicious code will lead to desaster. > > Protecting crypto/rand.Reader

Re: [go-nuts] fixed random number trouble

2018-03-15 Thread matthewjuran
crypto/rand is another option. I use the math/rand repeatability to be able to regenerate a picture made of random elements, where I modify the seed until I’m happy with the result but later I may need to re-render at different dimensions or with other parameters. Matt On Thursday, March 15,

[go-nuts] Re: [ANN] parwork - a fork-join package for processing work in parallel written in go

2018-03-14 Thread matthewjuran
Hi Sotirios, Why not something like this? // Stops and returns if any error is encountered by a work function, otherwise returns nil. // Processes work at the pace of runtime.NumCPU() parallelization. func Process(callback func(interface{}), work ...func() (interface{}, error )) error Matt On

Re: [go-nuts] Why should i use interface composistion

2018-03-13 Thread matthewjuran
Writing to be testable is good but ideally tests shouldn’t drive the app code. I’ll admit that I’ve written inconsistent database method patterns to enable testing but then never wrote tests. In that case there’s a global DB type (type DB struct { *sql.DB }) with a global var of the type

[go-nuts] Re: Why should i use interface composistion

2018-03-13 Thread matthewjuran
Interfaces are not for grouping variable behavior, interfaces are for allowing generic code to apply to varying data structures. Consider a struct of function fields for grouping variable behavior without a backing data structure. If your interface type is not an input in the same package then

[go-nuts] Re: Are you doing unit, module, and systems tests? If not, why not?

2018-03-13 Thread matthewjuran
I have less than ten years of experience doing this, but: The rule is that if you don’t verify it then it’s going to break in deployment, 100% of the time. In my experience you can get away without testing small changes with software if you’re very careful about verifying the change with

[go-nuts] Re: constructors vs lazy initialization

2018-03-11 Thread matthewjuran
> > I prefer the later when possible because it enables callers to use the > zero value of a type without explicit initialisation. Two great standard library examples of this are sync.Mutex / sync.RWMutex and bytes.Buffer / strings.Builder. Matt On Saturday, March 3, 2018 at 9:20:11 PM

[go-nuts] Re: Flutter and golang

2018-03-11 Thread matthewjuran
For my web application I previously reached the conclusion that the best approach is to write independent clients with the platform programming and visual design language instead of trying something cross-platform. I can see Flutter or QT being great for “we need this to work everywhere and

[go-nuts] Re: [ANN] Get Programming with Go

2018-03-09 Thread matthewjuran
I may have been pushing my own agenda more than what the Go project is actually about with this: Perhaps something like “Go is designed for programming modern computers and > computer systems in English” would be more accurate? This 2012 talk does indicate that Go is about Google-style

[go-nuts] Re: My views on Go and why it's better than Scripting

2018-03-09 Thread matthewjuran
My statement earlier is wrong: The Go 1 compatibility approach may be worth mentioning: programs written > in 2009 will still work in 2019 with the state of the art compiler. Go 1 was actually 2012, not 2009. Also Go 2 may start at some point soon, so maybe "programs written in 2012 will

[go-nuts] Re: Building Go

2018-03-08 Thread matthewjuran
While an old Go program will compile with new versions, new Go programs may not compile with old versions due to added standard library APIs. Matt On Thursday, March 8, 2018 at 10:32:35 AM UTC-6, Krzysztof Kwiatkowski wrote: > > Hi, > > > I've quite newbe question, but I would like to

Re: [go-nuts] Re: [ANN] Get Programming with Go

2018-03-08 Thread matthewjuran
> > I'm not sure if "in English" really describes Go. Languages like Ruby > purport to offer English-like syntax (see "Beautiful Code: Leading > Programmers Explain How They Think") through metaprogramming tricks. On the > other hand, Go strives for simplicity and, in my opinion, clarity --

[go-nuts] Re: [ANN] Get Programming with Go

2018-03-07 Thread matthewjuran
> > Go is designed for the modern data center, but its adoption isn’t > restricted to the workplace. While the garbage collector may point to this, and I’ve previously argued about data centers stepping on other applications’ feet, my understanding is the stated goal is systems programming.

Re: [go-nuts] Re: General question: complex search form and query params

2018-03-04 Thread matthewjuran
> > Unless I'm misunderstanding something, that kind of string concatenation > looks dangerous to me. This approach may be error prone so testing is important but I believe the database/sql placeholders avoid any SQL injection. Here the caller also has responsibility to validate the input

[go-nuts] Re: My views on Go and why it's better than Scripting

2018-03-03 Thread matthewjuran
I like Go because it improves on C for engineers in almost every way and avoids classes, and, at least today, if you have a problem then it will be solved quickly by the people following the GitHub issue tracker and contributing to the source code. Go avoids complexities such as generics (aka

[go-nuts] Re: General question: complex search form and query params

2018-03-03 Thread matthewjuran
Mapping a subset DSL to SQL doesn’t sound too difficult since SQL already has those boolean expressions and such. The database/sql library uses context for cancellation, so queries that take too long could be cancelled by a timer goroutine. One thing for me that would be helped by a library is

[go-nuts] Re: How to limit what the `go get` command is able to import

2018-03-02 Thread matthewjuran
How do you stop people from downloading and deploying arbitrary python or java libs? I can see that more than a developer policy is needed since it takes a corrupt employee only one try to break the system before they’re caught, and if the employee actually just made a mistake then firing them

[go-nuts] Re: General question: complex search form and query params

2018-03-02 Thread matthewjuran
> > To prevent SQL injection and for flexibility, I'm set on using an sql > builder library. I believe correctly used database/sql (with the argument placeholders) protects against SQL injection. There’s a query builder for postgres with MIT license posted here a few days ago:

[go-nuts] Re: [ANN] Loukoum: a simple SQL Query Builder with reusable components

2018-02-27 Thread matthewjuran
Hi Thomas, I’ve thought about writing something like this. My postgreSQL queries go through database/sql and github.com/lib/pq and are concatenated strings with + and constants in most cases, and sometimes with Sprintf to write an index naming a column. This approach is hard to read. I have

  1   2   3   >