[go-nuts] pyrmid print (possible?)

2020-03-02 Thread Rustem Satimov
Well, i have to mention , pyramid like algo , which is quite complicated using with other nodes and structures but a little question of main goal of mine numbers to follow : 10.. from kind of array [ a b c ] [ d e f ] [ g h i ] [ end end end ] so output should be like: L1 - a , L2 - b , L3 -

[go-nuts] Exclusion of `XXX` fields from unmarshalled objects when using protocmp and protoreflect

2020-03-02 Thread 'Timothy Fall' via golang-nuts
Hi Guys! I've been working on a transient problem in the github.com/kubernetes/client-go library that keeps us from using an updated version of github.com/googleapis/gnostic. The tl;dr on the problem (which serves as background for my question) is that the tests make heavy use of `reflect.DeepE

Re: [go-nuts] Language proposal: labelled "with" statements to help make test code easier to write

2020-03-02 Thread peterGo
Warren, "The over-arching goal is for me to write tests more easily. Not avoid writing tests. I am not arguing against tests." Here is a quick fix of your code; ws.go: https://play.golang.org/p/KgQ0esiY0Xt Now, use rdr to quickly test countSomeStuff: ws_test.go: https://play.golang.org/p/1

Re: [go-nuts] Language proposal: labelled "with" statements to help make test code easier to write

2020-03-02 Thread Robert Engels
In the specific case you cite, it seems doubtful to me that you couldn’t properly test a 60 line method fully externally/black box > On Mar 2, 2020, at 3:32 PM, Robert Engels wrote: > >  > That’s where people management. Seasoned vets are better off devoting energy > to changing things than f

Re: [go-nuts] Language proposal: labelled "with" statements to help make test code easier to write

2020-03-02 Thread Robert Engels
That’s where people management. Seasoned vets are better off devoting energy to changing things than fighting fires - much better in the long run imo. > On Mar 2, 2020, at 2:53 PM, Warren Stephens > wrote: > >  > Robert, > > I just feel like (somehow invariably!) breaking 60 line methods in

Re: [go-nuts] Language proposal: labelled "with" statements to help make test code easier to write

2020-03-02 Thread Warren Stephens
Robert, I just feel like (somehow invariably!) breaking 60 line methods into 3 methods of 20 lines each is not the best ultimate solution. As for the "real world" ...this is too funny.. I must live in a different one than most -- I have received 2 high-priority urgent requests since my previou

Re: [go-nuts] Language proposal: labelled "with" statements to help make test code easier to write

2020-03-02 Thread Robert Engels
Then, as someone else pointed out, use black-box testing. Test only the public/external API. If your code is too complex to be tested this way, that's a sign of structure than needs to be refactored.I don't think "it's the real world" will get much traction here - people that maybe started their ca

Re: [go-nuts] Re: Language proposal: labelled "with" statements to help make test code easier to write

2020-03-02 Thread Warren Stephens
Axle, Maybe with would need to be some sort of "freeze the variables" (no redefinition) statement? -- I am going to think about it. Warren -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails

Re: [go-nuts] Language proposal: labelled "with" statements to help make test code easier to write

2020-03-02 Thread Warren Stephens
The over-arching goal is for me to write tests more easily. Not avoid writing tests. I am not arguing against tests. Though I am being a bit snarky when I see responses that seem merely to say "Use TTD or something similar and it will solve all your problems!" I have never experienced that w

Re: [go-nuts] Language proposal: labelled "with" statements to help make test code easier to write

2020-03-02 Thread Tristan Colgate
While pure TDD as defined by its canonical text can be frustrating and time consuming, simply not writing tests is not really a defensible position, and definitely not one that Go, or any other language, should attempt to make easier. Writing testable code, and writing tests, does not have to mea

Re: [go-nuts] Re: Language proposal: labelled "with" statements to help make test code easier to write

2020-03-02 Thread 'Axel Wagner' via golang-nuts
On Mon, Mar 2, 2020 at 2:05 PM Warren Stephens wrote: > What if local var pointers (like x above) were invalid to list in a *with* > statement? > > Would there then be any other breaking examples? Can it be broken using > passed pointers or heap pointers? > Of course. In fact, that was my thoug

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

2020-03-02 Thread Jake Montgomery
Good explanation, Marvin. This is precisely why we have the race detector. If all races produced a panic, then it would not be needed. Some races behave "correctly" for a long time, and only on rare occasion result in silent data corruption that can be almost impossible to debug. Other races mi

Re: [go-nuts] Language proposal: labelled "with" statements to help make test code easier to write

2020-03-02 Thread Warren Stephens
Misha, Wonderful! This view is the furtherest away from mere TDD "virtue signaling"! Warren -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubs

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 pani

Re: [go-nuts] Language proposal: labelled "with" statements to help make test code easier to write

2020-03-02 Thread Mikhail Gusarov
On 2 Mar 2020, at 13:54, Warren Stephens wrote: Note to others: Software *Engineers* must operate with the 3-way tradeoff in mind (pick 2 is the old joke): 1. quality (good) 2. time (fast) 3. cost (cheap) Well, if you are taking "engineering" out of sheaf, then the following essent

Re: [go-nuts] Re: Language proposal: labelled "with" statements to help make test code easier to write

2020-03-02 Thread Warren Stephens
Axel, What if local var pointers (like x above) were invalid to list in a *with* statement? Would there then be any other breaking examples? Can it be broken using passed pointers or heap pointers? Warren -- You received this message because you are subscribed to the Google Groups "golang-

Re: [go-nuts] Re: Language proposal: labelled "with" statements to help make test code easier to write

2020-03-02 Thread Warren Stephens
Axel, I think it was a different kind of efficiency that first prompted my thinking on this. The (my) original prompting code was written quickly, debugged, and working. No tests. Such is life. The refactored "testable" code (no functionality added) became 162 lines and 9 funcs -- averaging

[go-nuts] Re: Language proposal: labelled "with" statements to help make test code easier to write

2020-03-02 Thread Brian Candler
Tests that depend on the internal implementation of a function are very brittle: any refactoring and they're likely to break, which defeats much of the benefit. You can check that a function has the required visible behaviour without hooking directly into its internals, by comparing the state o

[go-nuts] Re: Is the result of FindStringSubmatch correct?

2020-03-02 Thread Brian Candler
Or closer to your original code, FindAllStringSubmatch . https://play.golang.org/p/Tiva8X425k3 -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop r

[go-nuts] Re: Is the result of FindStringSubmatch correct?

2020-03-02 Thread Brian Candler
Perhaps you were confused by this in the documentation : "...and the matches, if any, of its subexpressions, as defined by the 'Submatch' descriptions in the package comment" That means one value per actual parenthesised subexpression in the or

[go-nuts] Re: Language proposal: labelled "with" statements to help make test code easier to write

2020-03-02 Thread John Arundel
On Saturday, 29 February 2020 18:11:53 UTC, Warren Stephens wrote: > > The influence that test code has on the structure of the application code > is highly undesirable. > On the contrary, I think designing for testability improves your architecture considerably! And if you develop test-first,

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

2020-03-02 Thread Brian Candler
On Monday, 2 March 2020 04:49:34 UTC, Yuan Ting wrote: > > 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 wh

[go-nuts] Is the result of FindStringSubmatch correct?

2020-03-02 Thread sleepy
https://play.golang.org/p/YoNyiKo-lTc package main import ( "fmt" "regexp" ) func main() { s := `([^ ]+ ?)*` re := regexp.MustCompile(s) fmt.Printf("%q\n", re.FindStringSubmatch("aaa bbb ccc")) } I expect the output to be: > ["aaa bbb ccc" "aaa " "bbb " "ccc"] > > but the actual output is: >