Re: [go-nuts] Re: Design patterns in Go

2024-04-04 Thread alex-coder
Hi All,

in case someone is in interest of the subject I repost here what I have 
found in the internet some time ago.
>>I apologize for being so intrusive.
>>I will only provide links to educational resources, in case it would be 
interesting for anyone.
>>GitHub - AlexanderGrom/go-patterns: Design patterns in Golang 
 (in russian)
>>Go Patterns · GitBook (tmrts.com) 
>>GitHub - PacktPublishing/Go-Design-Patterns-for-Real-World-Projects: Go: 
Design Patterns for Real-World Projects, by Packt 

>>Patrones de Diseño en Go (designpatternsingo.com) 
 (in spanish)

But I would like to stress one thing.
Due to absence in GO dynamic dispatching some of the patterns must be 
implemented, say as they must be in GO. :-)

Thank you.

понедельник, 1 апреля 2024 г. в 19:20:17 UTC+3, Ionenet SA: 

> I think many of you are confusing things. Many GOF patterns are still the 
> basis of today's programming. For example, the way that React or Vue manage 
> states, whatever you are using Pinia or Redux, they are no more than the 
> Observer pattern combined with the Proxy. And they are now native in 
> vanilla JavaScript. The observer is at the basis of event driven 
> programming. The Model-View-Controller itself is another combination of GOF 
> patterns. All the lambda functionality is an application of the Strategy 
> pattern and there are plenty of examples in modern programming that they 
> are nothing more than patterns. All the Martin Fowler's patterns are 
> nothing more than a combination of GOF patterns. The entire functionality 
> of history and ctrl+z/ctrl+y functionality is nothing more than a 
> combination of State/Memento. So I disagree completely about the idea that 
> patterns are to overcome Java limitations. The fact that some modern 
> languages natively implement a pattern in the form of a construct (for 
> example lambda functions to implement strategy) does not make the patterns 
> useless, but rather illustrate their usefulness.
>
> So, while some patterns are useless today, while some others are natively 
> implemented in many languages, including PHP, knowing them is still very 
> useful to understand how things work and where they come from. Otherwise 
> you will get submerged by a myriad of fancy names (in Laravel's style) and 
> you have to figure out and finally learn the same wheel with a different 
> name and the incorrect way.
>
> Think about it.
>
> On Wednesday, March 19, 2014 at 2:15:02 PM UTC-4 DV wrote:
>
>> My interpretation of what was said above was more along the lines that 
>> some of the patterns in the gang-of-four book exist not because they're 
>> good patterns in themselves, but that they exist because the languages they 
>> were designed for have various shortcomings and a certain type rigidness 
>> that doesn't exist in Go, so why bother using them? 
>>
>> Some sort of AbstractFactoryOfFactoryFactories is always present in every 
>> non-trivial Java project I've ever seen, but almost nobody bothers with it 
>> in Go. If that pattern is difficult to implement in Go (it might be, I 
>> never tried) what does that tell us about Go? That Go is bad at 
>> implementing bad/unnecessary patterns? I can live with that, definitely. 
>> The more important question though is - why even bother with that "pattern" 
>> in Go? 
>>
>> I think we need to look at the problems, and try to solve them in Go, not 
>> look at a problem, take an existing Java solution and then translate it to 
>> Go. 
>>
>> 19/20 "patterns" I've seen about Go are about concurrency and how to use 
>> goroutines, channels, select, etc. to solve common concurrency problems, *in 
>> Go*. They're not abstract UML diagrams about problems that may not even 
>> exist in Go or other languages, which is what the GoF book is to me - 
>> answers to questions that nobody is asking. 
>>
>>
>> On Wednesday, March 19, 2014 11:16:43 AM UTC-6, Robert Johnstone wrote:
>>>
>>> I think that you misunderstood my point.  My point was that since 
>>> languages differ in their level of abstraction, the level of abstraction 
>>> for the design patters will also vary.  Judging the quality of a language 
>>> based on the level of abstraction of its design patterns is just as odd an 
>>> idea as judging the language based its level of abstraction directly.  
>>>
>>> Beyond the above, it's not clear why patterns should be said to raise 
>>> the level of abstraction in one case and lower it in another.
>>>
>>>
>>> On Wednesday, 19 March 2014 11:25:56 UTC-4, Péter Szilágyi wrote:

 Hi,

   Take care not to mix up design patterns and levels of abstractions. 
 Although we could argue that building function calls on top of assembly is 
 a "pattern", it is one that raises the level of abstraction. The design 
 patterns of GoF on the 

[go-nuts] Re: Any option to substitute plug-in package ?

2023-10-28 Thread alex-coder
Hi all.

Of course, in case if anyone is in interest to write  plugins for Go.
I found another option for writing plugins by use Lua.
I haven't touched the example yet, but I'm giving out the link.
https://github.com/yuin/gopher-lua/

Thank you.

четверг, 3 августа 2023 г. в 15:47:26 UTC+3, alex-coder: 

> Hi All,
> Currently I walk through the next book about native go development and 
> find out that it is possible to use the plugin, 
> but with limitations, so it became interesting what alternatives there are.
>
> Thank you.
>
> четверг, 3 августа 2023 г. в 12:09:21 UTC+3, Christoph Berger: 
>
>> WebAssembly comes to mind - see, for example, https://wazero.io/
>>
>> A plugin would then be a .wasm binary that can be compiled in any 
>> language that supports WebAssembly as target.
>>
>> Disclaimer: I have not yet tried this approach.
>>
>> On Wednesday, August 2, 2023 at 12:14:15 PM UTC+2 alex-coder wrote:
>>
>> Hi All !
>> Plug-in package is very interesting, but in case the development under 
>> windows it does not work,
>> So, any hint to use some option instead will be highly appreciated.
>>
>> Thank you.
>>
>>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/5bce322e-df4a-46c4-8a3d-35b025e73a44n%40googlegroups.com.


[go-nuts] Re: Best IDE for GO ?

2023-08-23 Thread alex-coder
Hi All !

Considering that IBM's punch cards were bearing at least twice, I would 
vote for them. :-)

Of cource I do agree with them who wrote that to feel comfortable "under 
fingers" is great !

So, the tasks to code - they are different. 
Sometimes it is possible to keep all the details regards to the task in a 
head or several.
Sometimes it is nesessary to write say a hard copy of them(details) on a 
paper with a different size.

But in case the task from the area of the "poorly formalized". You spend 
paper quickly. :-)

The Luke Crook points to:
https://en.wikipedia.org/wiki/Application_lifecycle_management

I will simplify the task somewhat and take from ALM for example even less 
than SDLC, namely:
requirements, design, implementation, testing, deployment.

1. Requirements must be described somewhere.
2. Design artifacts should reflect requirements.
3. Design decisions refer to objects and messages that
implemented in the form of classes and operations.
4. Each operation must pass at least one test.
All tests must be passed successfully.
5. The application is assembled and installed there and 
the tests are successfully passed again.

Question: is there any IDE or plugin which one support that kind of 
dependencies in a graphical mode ?

Thank you.

вторник, 22 августа 2023 г. в 18:22:52 UTC+3, Mike Schinkel: 

> On Saturday, August 19, 2023 at 5:27:34 AM UTC-4 alex-coder wrote:
>
> What I'm looking for is the ability to manage dependencies not only in 
> code,
> but entirely in a project from requirements to deployment.
>
>
> I assume you mean a lot more than just Go package dependencies, as `go 
> mod` handles those nicely.
>
> Can you elaborate on the specific dependencies you are trying to manage?  
> In specific, vs generalities.
>
> -Mike  
>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/db0e5232-9044-4fc1-8b13-a954b4b46d3fn%40googlegroups.com.


[go-nuts] Best IDE for GO ?

2023-08-19 Thread alex-coder
Hi All !
Gophers, there is at least 10 years as GO on a market, Good job !

I found a list of the best IDE and Plugins there:
https://github.com/golang/go/wiki/IDEsAndTextEditorPlugins

As I remember Java came around 1995 and within 3-4 years several companies 
developed really great IDEs successful or less to develop commercial 
project 
on Java. Here is a list of but I may miss somewhat, sorry, 
it was relatively a long time ago:

Forte for Java ( Praga, Czech republic)
VisualCafe (Symantec)
VisuailAge (IBM)
JBuilder (Borland)
Together Control Center (TogetherSoft, Germany)
Eclipse, and set of commercial IDE on a base on: RSA,RSD,WID and so on (IBM)

appear later:

VS Code ( Microsoft)
IDEA (JetBrain)

What I'm looking for is the ability to manage dependencies not only in 
code, 
but entirely in a project from requirements to deployment.
The feature should be inbuild into IDE or at least it would be possible 
to write plugin to implement it.

It is quite possible that I'm missing somewhat here.
Gophers, may be there is another place where I should look for IDE for GO ?

Thank you.

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/61fefbf1-bb6d-4d90-b77b-a94c70582826n%40googlegroups.com.


[go-nuts] Re: Any option to substitute plug-in package ?

2023-08-03 Thread alex-coder
Hi All,
Currently I walk through the next book about native go development and find 
out that it is possible to use the plugin, 
but with limitations, so it became interesting what alternatives there are.

Thank you.

четверг, 3 августа 2023 г. в 12:09:21 UTC+3, Christoph Berger: 

> WebAssembly comes to mind - see, for example, https://wazero.io/
>
> A plugin would then be a .wasm binary that can be compiled in any language 
> that supports WebAssembly as target.
>
> Disclaimer: I have not yet tried this approach.
>
> On Wednesday, August 2, 2023 at 12:14:15 PM UTC+2 alex-coder wrote:
>
> Hi All !
> Plug-in package is very interesting, but in case the development under 
> windows it does not work,
> So, any hint to use some option instead will be highly appreciated.
>
> Thank you.
>
>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/5ad7ddd5-c6de-486a-be89-4b6daf008729n%40googlegroups.com.


[go-nuts] Re: Any option to substitute plug-in package ?

2023-08-03 Thread alex-coder
Hi All,

so, binary code plugin as a RPC - frankly, never thought about :-)

What is written in go spec is a 
>> dynamically discovering and loading *shared lib*
as I see it but community developed much further

Thank you.

среда, 2 августа 2023 г. в 15:03:38 UTC+3, TheDiveO: 

> It really depends on what you want to achieve...
>
>1. dynamically discovering *out-of-process* RPC plugins ... 
>Hashicorp's might be the most famous one.
>2. dynamically discovering and loading *shared lib *plugins ... this 
>needs some plumbing above the pure stdlib plugin functionality. 
> Personally, 
>I find the shared libs to be finicky and haven't yet done a real project 
>that needed this variant (but I wrote a go-plugger 
><https://github.com/thediveo/go-plugger> module as an example).
>3. statically binary-builtin plugins: this actually is what I tend to 
>use in several of my own projects, where there is no need for dynamically 
>extending but instead to easily maintain and use a fixed set of "plugins" 
>and that set of plugins tends to slowly grow. The plugin mechanism might 
>help organizing, such as my own go-plugger 
><https://github.com/thediveo/go-plugger> supporting type-safe plugin 
>APIs and ordering and iterating plugins at runtime. For instance, I use 
>this mechanism to simplify adding new types to factories, or to "decorate" 
>containers with additional labels, such as in Docker compose contexts, or 
>k8s contexts, or ...
>
>
> On Wednesday, August 2, 2023 at 12:14:15 PM UTC+2 alex-coder wrote:
>
>> Hi All !
>> Plug-in package is very interesting, but in case the development under 
>> windows it does not work,
>> So, any hint to use some option instead will be highly appreciated.
>>
>> Thank you.
>>
>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/ee812683-6265-45d0-9de5-711859094a8bn%40googlegroups.com.


[go-nuts] Any option to substitute plug-in package ?

2023-08-02 Thread alex-coder
Hi All !
Plug-in package is very interesting, but in case the development under 
windows it does not work,
So, any hint to use some option instead will be highly appreciated.

Thank you.

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/ad934244-7fe9-41b2-ad2a-e48b4460a287n%40googlegroups.com.


[go-nuts] Re: How to run extra routine for http server properly ?

2023-07-07 Thread alex-coder
Yes, the question is set too broadly, it is necessary to specify the 
context, 
thank you.

четверг, 6 июля 2023 г. в 02:33:18 UTC+3, ben...@gmail.com: 

> For simple things, you can fire up a goroutine to do the "something else" 
> after the request finishes. For example, I've used this before to kick off 
> sending an email to a customer in the background (you'll want to 
> handle/report errors somehow though):
>
> package main
>
> import (
> "fmt"
> "log"
> "net/http"
> "time"
> )
>
> func main() {
> http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
> fmt.Fprint(w, "sending email in the background")
> go sendEmail()
> // response is sent, but sendEmail goroutine continues
> })
> log.Print("listening on http://localhost:8080;)
> http.ListenAndServe(":8080", nil)
> }
>
> func sendEmail() {
> log.Printf("would send an email here")
> time.Sleep(time.Second)
> log.Printf("done sending email")
> }
>
> On Thursday, July 6, 2023 at 2:03:47 AM UTC+12 alex-coder wrote:
>
> Hi All !
>
> So, http server looks like is a request / response processing.
> But in case it is nesessary to do something else after the response has 
> been sent to the client, how to do it properly ?
> Is there any example to read ?
>
> Thank you.
>
>
>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/e8d9e2db-7c10-4d14-aee7-3a1625f1c22an%40googlegroups.com.


[go-nuts] How to run extra routine for http server properly ?

2023-07-05 Thread alex-coder
Hi All !

So, http server looks like is a request / response processing.
But in case it is nesessary to do something else after the response has 
been sent to the client, how to do it properly ?
Is there any example to read ?

Thank you.


-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/a2bb1c86-76ac-45bc-a096-99cf54b41aadn%40googlegroups.com.


[go-nuts] Re: tool for ast graph visualization

2023-06-15 Thread alex-coder
Thank you so much !

четверг, 15 июня 2023 г. в 13:28:52 UTC+3, Vraj Reshamdalal: 

> Hi alex-coder,
> To get ast for GO code in a json format you can try a web tool: 
> https://astexplorer.net/
> or
> https://github.com/asty-org/asty
>
> Thanks,
> Vraj
>
> On Thursday, June 15, 2023 at 9:31:54 AM UTC+5:30 alex-coder wrote:
>
>> Xa, context is the king on a field :-)
>>
>> You gave a good sample, and I would like to get ast for GO code in a json 
>> format for further processing.
>>
>>
>> четверг, 15 июня 2023 г. в 01:45:20 UTC+3, ben...@gmail.com: 
>>
>>> Hi Alex, could you please give a bit more context about what language or 
>>> kind of AST you're referring to, and what you mean by visualize? As Vraj 
>>> mentioned, Graphviz is good for the general case. If you just want to 
>>> "visualize" Go AST in a text format, you can use go/ast.Print: 
>>> https://pkg.go.dev/go/a...@go1.20.5#Print 
>>> <https://pkg.go.dev/go/ast@go1.20.5#Print>
>>>
>>> On Wednesday, June 14, 2023 at 9:14:37 AM UTC+12 alex-coder wrote:
>>>
>>>> Hi All !
>>>>
>>>> Could you please advice me a tool to visualize an ast graph.
>>>>
>>>> Thank you.
>>>>
>>>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/a84edcb7-e69c-4c7a-bf50-481d01c549e3n%40googlegroups.com.


[go-nuts] Re: tool for ast graph visualization

2023-06-14 Thread alex-coder
Xa, context is the king on a field :-)

You gave a good sample, and I would like to get ast for GO code in a json 
format for further processing.


четверг, 15 июня 2023 г. в 01:45:20 UTC+3, ben...@gmail.com: 

> Hi Alex, could you please give a bit more context about what language or 
> kind of AST you're referring to, and what you mean by visualize? As Vraj 
> mentioned, Graphviz is good for the general case. If you just want to 
> "visualize" Go AST in a text format, you can use go/ast.Print: 
> https://pkg.go.dev/go/a...@go1.20.5#Print 
> <https://pkg.go.dev/go/ast@go1.20.5#Print>
>
> On Wednesday, June 14, 2023 at 9:14:37 AM UTC+12 alex-coder wrote:
>
>> Hi All !
>>
>> Could you please advice me a tool to visualize an ast graph.
>>
>> Thank you.
>>
>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/26ca3c04-89dc-4225-80a5-d5ad5bd8219an%40googlegroups.com.


[go-nuts] tool for ast graph visualization

2023-06-13 Thread alex-coder
Hi All !

Could you please advice me a tool to visualize an ast graph.

Thank you.

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/a74735a2-ab83-4f6a-8974-138fd5433dden%40googlegroups.com.


[go-nuts] Hosting to deploy && run exe ?

2023-06-11 Thread alex-coder
Hi All !

Could you please advise me the simple  hosting to deploy && run a small exe 
assembled from go.

Thank you !

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/8ab9fc50-3671-4eb6-a5e6-2feef19fdb84n%40googlegroups.com.


[go-nuts] ast package design / improvement discussion. where to read ?

2023-03-19 Thread alex-coder
Hi All !

Is there any discussion, which one possible to read, especially with 
rationale ?
Very interesting to read about walk.go file and callback of the  custom 
code.

Thank you.

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/d0354fde-e21c-4803-a882-02c11027325en%40googlegroups.com.


Re: [go-nuts] Help to choose the right type of the key for a map.

2023-03-18 Thread alex-coder
Ian and Andy,
looks like the to string conversion works and even does not look ugly. :-)

Thank you so much.

пятница, 17 марта 2023 г. в 15:01:31 UTC+3, alex-coder: 

> Andy, thank you.
>
> In case there would be a choice between ugly and achievable, I must take 
> the last one:-)
>
> Another thing I have found it that it is impossible to use type as a 
> parameter when you call to a function.
> How to pass type to function argument in Go - Stack Overflow 
> <https://stackoverflow.com/questions/51097211/how-to-pass-type-to-function-argument-in-go>
>
> Thank you.
>
> пятница, 17 марта 2023 г. в 02:12:22 UTC+3, Andy Balholm: 
>
>> I would guess that in the case of AST nodes, you're likely more 
>> interested in the *identity* of the nodes than their *values*. In that 
>> case, you should use the pointers to the nodes as your map keys.
>>
>> If the *values* truly are what you care about, use the go/format package 
>> to convert the node back to source code, and use the resulting string as 
>> your map key.
>>
>> On Thursday, March 16, 2023 at 3:24:49 PM UTC-7 alex-coder wrote:
>>
>>> >> Sure, convert to a string and use that as a map key.
>>> :-) no, no, no. it looks very very ugly.
>>>
>>> четверг, 16 марта 2023 г. в 00:26:35 UTC+3, Ian Lance Taylor: 
>>>
>>>> On Wed, Mar 15, 2023 at 2:16 PM alex-coder  wrote: 
>>>> > 
>>>> > Ian, thank you. 
>>>> > but may be the is any workaround ? 
>>>> > Use as a key not directly but like a derived from those 
>>>> interface/structure types ? 
>>>> > Of course I may declare key like string and use switch + .(type) to 
>>>> mimic it. 
>>>>
>>>> Sure, convert to a string and use that as a map key. 
>>>>
>>>> By the way, I should say that although you can't use `ast.Field` as a 
>>>> map key type, you can use `*ast.Field`. Of course then two different 
>>>> Field values that happen to look exactly the same will get different 
>>>> map entries. So it kind of depends on what you want to do. 
>>>>
>>>> Ian 
>>>>
>>>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/1a6849b1-35ae-4d3d-bdd9-28d5b342bcb9n%40googlegroups.com.


Re: [go-nuts] Help to choose the right type of the key for a map.

2023-03-17 Thread alex-coder
Andy, thank you.

In case there would be a choice between ugly and achievable, I must take 
the last one:-)

Another thing I have found it that it is impossible to use type as a 
parameter when you call to a function.
How to pass type to function argument in Go - Stack Overflow 
<https://stackoverflow.com/questions/51097211/how-to-pass-type-to-function-argument-in-go>

Thank you.

пятница, 17 марта 2023 г. в 02:12:22 UTC+3, Andy Balholm: 

> I would guess that in the case of AST nodes, you're likely more interested 
> in the *identity* of the nodes than their *values*. In that case, you 
> should use the pointers to the nodes as your map keys.
>
> If the *values* truly are what you care about, use the go/format package 
> to convert the node back to source code, and use the resulting string as 
> your map key.
>
> On Thursday, March 16, 2023 at 3:24:49 PM UTC-7 alex-coder wrote:
>
>> >> Sure, convert to a string and use that as a map key.
>> :-) no, no, no. it looks very very ugly.
>>
>> четверг, 16 марта 2023 г. в 00:26:35 UTC+3, Ian Lance Taylor: 
>>
>>> On Wed, Mar 15, 2023 at 2:16 PM alex-coder  wrote: 
>>> > 
>>> > Ian, thank you. 
>>> > but may be the is any workaround ? 
>>> > Use as a key not directly but like a derived from those 
>>> interface/structure types ? 
>>> > Of course I may declare key like string and use switch + .(type) to 
>>> mimic it. 
>>>
>>> Sure, convert to a string and use that as a map key. 
>>>
>>> By the way, I should say that although you can't use `ast.Field` as a 
>>> map key type, you can use `*ast.Field`. Of course then two different 
>>> Field values that happen to look exactly the same will get different 
>>> map entries. So it kind of depends on what you want to do. 
>>>
>>> Ian 
>>>
>>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/b6ea9156-f4fd-4cf9-9a51-5942f5cbe715n%40googlegroups.com.


Re: [go-nuts] Help to choose the right type of the key for a map.

2023-03-16 Thread alex-coder
>> Sure, convert to a string and use that as a map key.
:-) no, no, no. it looks very very ugly.

четверг, 16 марта 2023 г. в 00:26:35 UTC+3, Ian Lance Taylor: 

> On Wed, Mar 15, 2023 at 2:16 PM alex-coder  wrote:
> >
> > Ian, thank you.
> > but may be the is any workaround ?
> > Use as a key not directly but like a derived from those 
> interface/structure types ?
> > Of course I may declare key like string and use switch + .(type) to 
> mimic it.
>
> Sure, convert to a string and use that as a map key.
>
> By the way, I should say that although you can't use `ast.Field` as a
> map key type, you can use `*ast.Field`. Of course then two different
> Field values that happen to look exactly the same will get different
> map entries. So it kind of depends on what you want to do.
>
> Ian
>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/f0556fc4-885a-4f13-a29e-1894983e5962n%40googlegroups.com.


Re: [go-nuts] Help to choose the right type of the key for a map.

2023-03-15 Thread alex-coder
Ian, thank you.
but may be the is any workaround ?
Use as a key not directly but like a derived from those interface/structure 
types ?
Of course I may declare key like string and use switch + .(type) to mimic 
it.

So, a little bit more.
there is a go standard package named ast. the docs about it you may find 
there:
ast package - go/ast - Go Packages <https://pkg.go.dev/go/ast>

there is an arrea where are declared a lot of types:
type ArrayType struct {}
type AssignStmt struct {}
type BadDecl struct {}
and so on and ending with 
type ValueSpec struct {}
in fact there are a lot of them there.
What do I whant is to use those types of interfaces or structures as a key 
to access to a value in a map.  
So, the question is: what type of a key for a map I must use ?

Thank you. 

среда, 15 марта 2023 г. в 23:55:03 UTC+3, Ian Lance Taylor: 

> On Wed, Mar 15, 2023 at 9:17 AM alex-coder  wrote:
> >
> > There is a package named ast, inside there are a lot of structures like:
> > ast.Comment, ast.Field, ast.Node and so on.
> > And I whould like to use types of those structure as a keys.
> > So, I could not figure out what type of the key I should use
> > in order to store in a map something under the key ?
>
> I don't really understand the question. But I do know that most of
> the types in the go/ast package can't be used as map keys, because
> they can't be compared for equality, because they have fields of slice
> type. You can't use a slice, or a struct with a field of slice type,
> as a map key.
>
> Ian
>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/dfc41f67-5d71-4f2a-a0bf-569c5a582aedn%40googlegroups.com.


[go-nuts] Re: Help to choose the right type of the key for a map.

2023-03-15 Thread alex-coder
the ast package it is possible to find there:
ast package - go/ast - Go Packages <https://pkg.go.dev/go/ast#pkg-types>

thank you.

среда, 15 марта 2023 г. в 19:16:59 UTC+3, alex-coder: 

> Hi All !
>
> There is a package named ast, inside there are a lot of structures like:
> ast.Comment, ast.Field, ast.Node and so on.
> And I whould like to use types of those structure as a keys.
> So, I could not figure out what type of the key I should use
> in order to store in a map something under the key ? 
>
> I'm in dubt here. Help !
>
> Thank you.
>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/326c7d3d-8e89-4a57-812f-41145d4190afn%40googlegroups.com.


[go-nuts] Help to choose the right type of the key for a map.

2023-03-15 Thread alex-coder
Hi All !

There is a package named ast, inside there are a lot of structures like:
ast.Comment, ast.Field, ast.Node and so on.
And I whould like to use types of those structure as a keys.
So, I could not figure out what type of the key I should use
in order to store in a map something under the key ? 

I'm in dubt here. Help !

Thank you.

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/03797dfe-f742-4861-b979-dfce710db3a8n%40googlegroups.com.


[go-nuts] Re: etcd, how to stop it ?

2023-01-16 Thread alex-coder
Brian, I can't thank you enough !
Sorry, button "Community" ofcourse.

понедельник, 16 января 2023 г. в 11:41:51 UTC+3, Brian Candler: 

> The homepage for etcd is here: https://etcd.io/  and there is a button 
> labelled "Community".
>
> You may also find this page useful: 
> http://www.catb.org/~esr/faqs/smart-questions.html#intro
>
> On Sunday, 15 January 2023 at 18:30:09 UTC alex-coder wrote:
>
>> Hi All !
>>
>> I do understand that my question is not quite in the right arrea,
>> but frankly, I'm totally lost.
>> I'm not able to find the answer for the looks like very simple question.
>> How to run - yes there is a sample, but how to stop it ?
>>
>> Thank you.
>>
>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/d59c05df-4c98-472d-83ae-9fd47020f52dn%40googlegroups.com.


[go-nuts] etcd, how to stop it ?

2023-01-15 Thread alex-coder
Hi All !

I do understand that my question is not quite in the right arrea,
but frankly, I'm totally lost.
I'm not able to find the answer for the looks like very simple question.
How to run - yes there is a sample, but how to stop it ?

Thank you.

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/74417268-f3a1-4951-a476-d2e7f335fe35n%40googlegroups.com.


Re: [go-nuts] Re: Design patterns. builder ?

2023-01-12 Thread alex-coder
Hi All !

In case some one is in interest of the builder patterm industrial 
implementation.
So, I have found that there are a very intresting use the package  named 
https://github.com/spf13/cobra.
The package should be considered In context of the builder pattern 
implementation for realizaton of the template pattern to implement 
command/fasade pattern.
And to say everything above a little bit simpler: package is used to build 
CLI.
Sorry, English is not native for me. :-)

Thank you.

суббота, 3 апреля 2021 г. в 14:13:39 UTC+3, alex-coder: 

> Hi, 
> thank you for  everyone!
>
> The main point here is: "generally isn't needed", but sometimes structure 
> does not come described properly in some kind of string representation. :-)
> the pair Func / funchandler - just excellent ! 
> But what about other GO-4 patterns, I mean "isn't needed in go" ?
> Where take a look at ?
>
> Thank you.
>
> On Thursday, April 1, 2021 at 4:29:14 PM UTC+3 ren...@ix.netcom.com wrote:
>
>> The Go protobufs impl uses the builder pattern. 
>>
>> On Apr 1, 2021, at 2:21 AM, Brian Candler  wrote:
>>
>> The builder pattern generally isn't needed in go, because go has 
>> flexible struct literals where you can omit any members you don't want. 
>>
>>
>> You can implement it if you like, but it just adds a layer of boilerplate:
>> https://gist.github.com/vaskoz/10073335
>>
>> Some people are drawn to functional options instead:
>> https://dave.cheney.net/2014/10/17/functional-options-for-friendly-apis
>>
>> https://www.calhoun.io/using-functional-options-instead-of-method-chaining-in-go/
>>
>> But if you look at the standard library as a source of inspiration and 
>> good practice, complex configuration is typically done via structs.  See 
>> for example http.Server <https://golang.org/pkg/net/http/#Server>
>>
>> -- 
>> 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...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/golang-nuts/39e38cd7-93ee-4084-89e4-a22bcd1baaa6n%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/golang-nuts/39e38cd7-93ee-4084-89e4-a22bcd1baaa6n%40googlegroups.com?utm_medium=email_source=footer>
>> .
>>
>>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/88d9f62e-4a2f-4623-8f50-0fdbb33f58f9n%40googlegroups.com.


[go-nuts] Re: go program import ?

2022-09-30 Thread alex-coder
Hi,

I have found data necessary to me there:
go/build.Default.GOROOT in case someone is in interest.

Thank you.

четверг, 29 сентября 2022 г. в 20:59:50 UTC+3, alex-coder: 

> Hi All,
>
> How I could detect programmatically that import in a go code
> belongs to a go distribution ?
>
> thank you very much for the answer.
>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/2cef1dbd-a226-43d1-8be3-b6b899e64881n%40googlegroups.com.


[go-nuts] go program import ?

2022-09-29 Thread alex-coder
Hi All,

How I could detect programmatically that import in a go code
belongs to a go distribution ?

thank you very much for the answer.

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/b4255c88-acda-41cd-8bf1-fcb08506f11dn%40googlegroups.com.


[go-nuts] Re: Java to Go converter - 2

2022-08-22 Thread alex-coder
Hi, sorry for delay.
Despite my great interest in this task, I can not spend a lot of time on 
the project. But you're right, everything I've posted on go-nuts shows that 
conversion is very possible and in the same context that you're 
considering, if I understand you correctly of course . So far it looks like 
this:
syntactic analysis,
semantic analysis,
then there is code generation on Go from AST.
Regards,

четверг, 18 августа 2022 г. в 21:58:03 UTC+3, Oliveira Jose Carlos de - 
ICTS BSA: 

> Hi, I´m looking foward to find a Tool able to convert any Java Source code 
> Project to a GoLang Project. I know that are Programming languages created 
> for different propposal. Java is OOL and  goLang is different. So 
> convertion is possible, but I think is very complex.  For me is much more 
> easy look on Java Source code logic and write your own code in GoLang.  I 
> think
>
> I did it in the past, and writting code in a new language make de new code 
> more maintenable.
>
> Em domingo, 22 de maio de 2022 às 03:49:42 UTC-3, alex-coder escreveu:
>
>> So, channels.
>> Converter can now convert Java classes to Go channels where possible. The 
>> previous example contains a Drop class that matches the conversion 
>> criteria, as shown in the Go example code below. Accordingly, if the 
>> converter "does not find" a class suitable for conversion, Java 
>> multithreading will be converted to Go code without using the translation 
>> into channels.
>> *Java code:*
>> package com.builder.start.here;
>>
>> import java.util.Random;
>>
>> public class RunMe {
>> public static void main(String[] args) {
>> Drop drop = new Drop();
>> (new Thread(new Producer(drop))).start();
>> (new Thread(new Consumer(drop))).start();
>> }
>> }
>> class Drop {
>> // Message sent from producer
>> // to consumer.
>> private String message;
>> // True if consumer should wait
>> // for producer to send message,
>> // false if producer should wait for
>> // consumer to retrieve message.
>> private boolean empty = true;
>>
>> public synchronized String take() {
>> // Wait until message is
>> // available.
>> while (empty) {
>> try {
>> wait();
>> } catch (InterruptedException e) {}
>> }
>> // Toggle status.
>> empty = true;
>> // Notify producer that
>> // status has changed.
>> notifyAll();
>> return message;
>> }
>>
>> public synchronized void put(String message) {
>> // Wait until message has
>> // been retrieved.
>> while (!empty) {
>> try { 
>> wait();
>> } catch (InterruptedException e) {}
>> }
>> // Toggle status.
>> empty = false;
>> // Store message.
>> this.message = message;
>> // Notify consumer that status
>> // has changed.
>> notifyAll();
>> }
>> }
>> class Consumer implements Runnable {
>> private Drop drop;
>>
>> public Consumer(Drop drop) {
>> this.drop = drop;
>> }
>>
>> public void run() {
>> Random random = new Random();
>> for (
>>String message = drop.take(); 
>>! message.equals("DONE"); 
>>message = drop.take()) {
>> System.out.format(
>>"MESSAGE RECEIVED: %s%n", message);
>>  try {
>> Thread.sleep(random.nextInt(5000));
>>} catch (InterruptedException e) {}
>> }
>> }
>> }
>> class Producer implements Runnable {
>> private Drop drop;
>>
>> public Producer(Drop drop) {
>> this.drop = drop;
>> }
>>
>> public void run() {
>> String importantInfo[] = {
>> "Mares eat oats",
>> "Does eat oats",
>> "Little lambs eat ivy",
>> "A kid will eat ivy too"
>> };
>> Random random = new Random();
>>
>> for (int i = 0; i < importantInfo.length; i++) {
>> drop.put(importantInfo[i]);
>> try {
>> Thread.sleep(random.nextInt(5000));
>> } catch (InterruptedException e) {}
>>   

[go-nuts] Re: Java to Go converter - 2

2022-05-22 Thread alex-coder
time.Duration(rand.Intn(n)) }
type Thread struct {
Runnable
}
func (t *Thread) run(wg *sync.WaitGroup) {
t.Runnable.run(wg)
}
type Runnable interface {
run(wg *sync.WaitGroup)
}

You can run code there:
Go Playground <https://go.dev/play/p/-y6f_rOa4EX>

Now I'll take a break, I need to deal with the advices that I received.
Thank you to all very much.
среда, 18 мая 2022 г. в 13:43:07 UTC+3, alex-coder: 

> Henry,
> thank you, it is quite possible that you are right, at least I should 
> check it out.
> Thank you again.
>
> среда, 18 мая 2022 г. в 07:39:49 UTC+3, Henry: 
>
>> Kudos to you. Java to Go is a lot of work. Java is a more complex 
>> language. It has more features and more possibilities for expressing the 
>> same model/algorithm. You need to identify all these possibilities, parse, 
>> and convert them to Go. I could be wrong about this, but it may be easier 
>> to convert Java bytecode to Go.   
>>
>> On Tuesday, May 17, 2022 at 9:49:09 PM UTC+7 alex-coder wrote:
>>
>>> In Go, multithreading is one of the main features, respectively, the 
>>> ability to convert Java code using multithreading into Go code 
>>> automatically, which uses channels, is very important.
>>> I found a suitable example of ProducerConsumerExample from Oracle 
>>> there:Oracle 
>>> sample 
>>> <https://docs.oracle.com/javase/tutorial/essential/concurrency/guardmeth.html>,
>>>  
>>> where the Drop class is a candidate for conversion to Go using channels.
>>> But, now I give an intermediate result without channels.
>>> Also, I read the opinion that the conversion of Java code where 
>>> annotations are used in runtime is impossible. It is necessary to 
>>> investigate the problem and try to understand if it is possible to solve it 
>>> somehow. Before transferring a project from the status of "possibility of 
>>> achievement" to the status of "prototype", it is necessary to see what can 
>>> be done with these problems in relation to annotations.
>>> *Java code:*
>>> package com.builder.start.here;
>>>
>>> import java.util.Random;
>>>
>>> public class RunMeDrop {
>>>
>>> public static void main(String[] args) {
>>> Drop drop = new Drop();
>>> (new Thread(new Producer(drop))).start();
>>> (new Thread(new Consumer(drop))).start();
>>> }
>>> }
>>> class Drop {
>>> // Message sent from producer
>>> // to consumer.
>>> private String message;
>>> // True if consumer should wait
>>> // for producer to send message,
>>> // false if producer should wait for
>>> // consumer to retrieve message.
>>> private boolean empty = true;
>>>
>>> public synchronized String take() {
>>> // Wait until message is
>>> // available.
>>> while (empty) {
>>> try {
>>> wait();
>>> } catch (InterruptedException e) {}
>>> }
>>> // Toggle status.
>>> empty = true;
>>> // Notify producer that
>>> // status has changed.
>>> notifyAll();
>>> return message;
>>> }
>>>
>>> public synchronized void put(String message) {
>>> // Wait until message has
>>> // been retrieved.
>>> while (!empty) {
>>> try { 
>>> wait();
>>> } catch (InterruptedException e) {}
>>> }
>>> // Toggle status.
>>> empty = false;
>>> // Store message.
>>> this.message = message;
>>> // Notify consumer that status
>>> // has changed.
>>> notifyAll();
>>> }
>>> }
>>> class Consumer implements Runnable {
>>> private Drop drop;
>>>
>>> public Consumer(Drop drop) {
>>> this.drop = drop;
>>> }
>>>
>>> public void run() {
>>> Random random = new Random();
>>> for (
>>>String message = drop.take(); 
>>>! message.equals("DONE"); 
>>>message = drop.take()) {
>>> System.out.format(
>>>"MESSAGE RECEIVED: %s%n", message);
>>>  try {
>>> Thread

[go-nuts] Re: Java to Go converter - 2

2022-05-18 Thread alex-coder
Henry,
thank you, it is quite possible that you are right, at least I should check 
it out.
Thank you again.

среда, 18 мая 2022 г. в 07:39:49 UTC+3, Henry: 

> Kudos to you. Java to Go is a lot of work. Java is a more complex 
> language. It has more features and more possibilities for expressing the 
> same model/algorithm. You need to identify all these possibilities, parse, 
> and convert them to Go. I could be wrong about this, but it may be easier 
> to convert Java bytecode to Go.   
>
> On Tuesday, May 17, 2022 at 9:49:09 PM UTC+7 alex-coder wrote:
>
>> In Go, multithreading is one of the main features, respectively, the 
>> ability to convert Java code using multithreading into Go code 
>> automatically, which uses channels, is very important.
>> I found a suitable example of ProducerConsumerExample from Oracle 
>> there:Oracle 
>> sample 
>> <https://docs.oracle.com/javase/tutorial/essential/concurrency/guardmeth.html>,
>>  
>> where the Drop class is a candidate for conversion to Go using channels.
>> But, now I give an intermediate result without channels.
>> Also, I read the opinion that the conversion of Java code where 
>> annotations are used in runtime is impossible. It is necessary to 
>> investigate the problem and try to understand if it is possible to solve it 
>> somehow. Before transferring a project from the status of "possibility of 
>> achievement" to the status of "prototype", it is necessary to see what can 
>> be done with these problems in relation to annotations.
>> *Java code:*
>> package com.builder.start.here;
>>
>> import java.util.Random;
>>
>> public class RunMeDrop {
>>
>> public static void main(String[] args) {
>> Drop drop = new Drop();
>> (new Thread(new Producer(drop))).start();
>> (new Thread(new Consumer(drop))).start();
>> }
>> }
>> class Drop {
>> // Message sent from producer
>> // to consumer.
>> private String message;
>> // True if consumer should wait
>> // for producer to send message,
>> // false if producer should wait for
>> // consumer to retrieve message.
>> private boolean empty = true;
>>
>> public synchronized String take() {
>> // Wait until message is
>> // available.
>> while (empty) {
>> try {
>> wait();
>> } catch (InterruptedException e) {}
>> }
>> // Toggle status.
>> empty = true;
>> // Notify producer that
>> // status has changed.
>> notifyAll();
>> return message;
>> }
>>
>> public synchronized void put(String message) {
>> // Wait until message has
>> // been retrieved.
>> while (!empty) {
>> try { 
>> wait();
>> } catch (InterruptedException e) {}
>> }
>> // Toggle status.
>> empty = false;
>> // Store message.
>> this.message = message;
>> // Notify consumer that status
>> // has changed.
>> notifyAll();
>> }
>> }
>> class Consumer implements Runnable {
>> private Drop drop;
>>
>> public Consumer(Drop drop) {
>> this.drop = drop;
>> }
>>
>> public void run() {
>> Random random = new Random();
>> for (
>>String message = drop.take(); 
>>! message.equals("DONE"); 
>>message = drop.take()) {
>> System.out.format(
>>"MESSAGE RECEIVED: %s%n", message);
>>  try {
>> Thread.sleep(random.nextInt(5000));
>>} catch (InterruptedException e) {}
>> }
>> }
>> }
>> class Producer implements Runnable {
>> private Drop drop;
>>
>> public Producer(Drop drop) {
>> this.drop = drop;
>> }
>>
>> public void run() {
>> String importantInfo[] = {
>> "Mares eat oats",
>> "Does eat oats",
>> "Little lambs eat ivy",
>> "A kid will eat ivy too"
>> };
>> Random random = new Random();
>>
>> for (int i = 0; i < importantInfo.length; i++) {
>> drop.put(importantInfo[i]);
>> try {
>>

[go-nuts] Re: Java to Go converter - 2

2022-05-17 Thread alex-coder
) {
defer wg.Done()

var random *Random = NewRandom()
for message := consumer.drop.take(); 
 message != "DONE"; 
 message = consumer.drop.take() {
fmt.Printf("MESSAGE RECEIVED: %s\n", message)
time.Sleep(random.nextInt(5000))
}
}

type Producer struct {
drop *Drop
}

func NewProducer(drop *Drop) *Producer {
var producer Producer = Producer{drop}
return 
}
func (producer *Producer) run(wg *sync.WaitGroup) {
defer wg.Done()

var importantInfo [4]string = [4]string{
"Mares eat oats",
"Does eat oats",
"Little lambs eat ivy",
"A kid will eat ivy too",
}

var random *Random = NewRandom()
for i := 0; i < len(importantInfo); i++ {
producer.drop.put([i])
time.Sleep(random.nextInt(5000))
}
s := "DONE"
producer.drop.put()
}

type Random struct{}

func NewRandom() *Random {
var random Random = Random{}
return 
}

func (r *Random) nextInt(n int) time.Duration { 
return time.Duration(rand.Intn(n)) 
}

type Thread struct {
Runnable
}

func (t *Thread) run(wg *sync.WaitGroup) {
t.Runnable.run(wg)
}

type Runnable interface {
run(wg *sync.WaitGroup)
}
The Go Playground, you can run code there:
Go Playground. <https://go.dev/play/p/o7tXt8p2m_3>

Thank you to all very much.

четверг, 28 апреля 2022 г. в 19:08:51 UTC+3, alex-coder: 

> So, multithreading.
> I found a simple example from Oracle with the wonderful name "Bad Threads" 
> there:
>
> https://docs.oracle.com/javase/tutorial/essential/concurrency/QandE/questions.html
>  
> , simplified it even more, called the example a new simple name One and 
> extend a Converter to translate the code to Golang.
> There is no similar processing for InterruptedException in go, so the 
> Converter does not translate the processing of this interrupt in any way. 
> If anyone has a relatively small example in Java, please share it.
> *Java code:*
> package run.me;
> public class One {
>   String msg;
>   public static void main(  String[] args) throws InterruptedException {
> One one=new One();
> one.msg="Initial message";
> System.out.println("main:before start:" + one.msg + " second part of");
> new Second(one).start();
> one.msg="after go start";
> Thread.sleep(2000);
> System.out.println("main:about to end:" + one.msg);
>   }
> }
> class Second extends Thread {
>   One one;
>   public Second(  One one){
> this.one=one;
>   }
>   public void run(){
> try {
>   sleep(1000);
> } catch (InterruptedException e) {
> }
> System.out.println("run:after sleep:" + one.msg);
> one.msg="try to change msg";
>   }
> }
> *Converter выдал:*
> package main
>
> import (
> "fmt"
> "os"
> "time"
> )
>
> type One struct {
> msg *string
> }
>
> func NewOne() *One {
> var one One = One{}
> return 
> }
> func main() {
> var args []string = os.Args
> var o_dummy *One = NewOne()
> o_dummy.One_main()
> }
>
> /** generated method **/
> func (one_one *One) One_main(args *[]string) {
> var one *One = NewOne()
> s := "Initial message"
> one.msg = 
> fmt.Println("main:before start:" + *one.msg + " second part of")
> go NewSecond(one).run()
> s_s := "after go start"
> one.msg = _s
> time.Sleep(2000)
> fmt.Println("main:about to end:" + *one.msg)
> }
>
> type Second struct {
> one *One
> }
>
> func NewSecond(one *One) *Second {
> var second Second = Second{one}
> return 
> }
> func (second *Second) run() {
> time.Sleep(1000)
> fmt.Println("run:after sleep:" + *second.one.msg)
> s_s_s := "try to change msg"
> second.one.msg = _s_s
> }
>
> The next example will probably be about channel's.
> If anyone has an interesting example, write me, I'll think about how to 
> solve it. I just can't promise that it will be quickly. :-)
>
> Thank you to all !
>
> четверг, 7 апреля 2022 г. в 18:52:25 UTC+3, alex-coder: 
>
>> Thanks for the comments about generating code to handle exceptions. . 
>> Here it is a new version.
>> package main
>>
>> import (
>> "fmt"
>> "os"
>> )
>>
>> type CatchException struct{}
>>
>> func main() {
>>
>> var args []string = os.Args
>>
>> var ce CatchException = CatchException{}
>

[go-nuts] Re: Java to Go converter - 2

2022-04-28 Thread alex-coder
So, multithreading.
I found a simple example from Oracle with the wonderful name "Bad Threads" 
there:
https://docs.oracle.com/javase/tutorial/essential/concurrency/QandE/questions.html
 
, simplified it even more, called the example a new simple name One and 
extend a Converter to translate the code to Golang.
There is no similar processing for InterruptedException in go, so the 
Converter does not translate the processing of this interrupt in any way. 
If anyone has a relatively small example in Java, please share it.
*Java code:*
package run.me;
public class One {
  String msg;
  public static void main(  String[] args) throws InterruptedException {
One one=new One();
one.msg="Initial message";
System.out.println("main:before start:" + one.msg + " second part of");
new Second(one).start();
one.msg="after go start";
Thread.sleep(2000);
System.out.println("main:about to end:" + one.msg);
  }
}
class Second extends Thread {
  One one;
  public Second(  One one){
this.one=one;
  }
  public void run(){
try {
  sleep(1000);
} catch (InterruptedException e) {
}
System.out.println("run:after sleep:" + one.msg);
one.msg="try to change msg";
  }
}
*Converter выдал:*
package main

import (
"fmt"
"os"
"time"
)

type One struct {
msg *string
}

func NewOne() *One {
var one One = One{}
return 
}
func main() {
var args []string = os.Args
var o_dummy *One = NewOne()
o_dummy.One_main()
}

/** generated method **/
func (one_one *One) One_main(args *[]string) {
var one *One = NewOne()
s := "Initial message"
one.msg = 
fmt.Println("main:before start:" + *one.msg + " second part of")
go NewSecond(one).run()
s_s := "after go start"
one.msg = _s
time.Sleep(2000)
fmt.Println("main:about to end:" + *one.msg)
}

type Second struct {
one *One
}

func NewSecond(one *One) *Second {
var second Second = Second{one}
return 
}
func (second *Second) run() {
time.Sleep(1000)
fmt.Println("run:after sleep:" + *second.one.msg)
s_s_s := "try to change msg"
second.one.msg = _s_s
}

The next example will probably be about channel's.
If anyone has an interesting example, write me, I'll think about how to 
solve it. I just can't promise that it will be quickly. :-)

Thank you to all !

четверг, 7 апреля 2022 г. в 18:52:25 UTC+3, alex-coder: 

> Thanks for the comments about generating code to handle exceptions. . Here 
> it is a new version.
> package main
>
> import (
> "fmt"
> "os"
> )
>
> type CatchException struct{}
>
> func main() {
>
> var args []string = os.Args
>
> var ce CatchException = CatchException{}
> ce.CatchException_main(args)
> }
>
> /** generated method **/
> func (catchException *CatchException) CatchException_main(args []string) {
> defer func() {
> if err := recover(); err != nil {
> exc := err.(Exception)
> switch exc.msg {
>
> case "Exception":
> fmt.Println("yes, I caught it")
> default:
> fmt.Println("No, something is not right")
> }
> }
> fmt.Println("finally processing")
> }()
>
> ({}).runme()
> }
>
> type ThrowException struct{}
>
> func (throwException *ThrowException) runme() {
> panic(Exception{"Exception"})
> }
>
> type Exception struct {
> msg string
> }
>
> понедельник, 4 апреля 2022 г. в 14:12:37 UTC+3, alex-coder: 
>
>>
>>
>>
>>
>> *Another use case for automatically translating codewritten in Java to 
>> Golang is Exception Handling.The next example is likely to be about 
>> multithreading.Example in Java:*
>> package com.builder.start.here;
>>
>> public class CatchException {
>>
>> public static void main(String[] args) {
>> try {
>> new ThrowException().runme();
>> } catch (Exception e) {
>> System.out.println("yes, I caught it");
>> } finally {
>> System.out.println("finally processing");
>> }
>>
>> }
>>
>> }
>>
>> class ThrowException{
>> public void runme() throws Exception{
>> throw new Exception();
>> }
>> }
>>
>> *Converter gave out:*
>>
>> package main
>>
>> import (
>> "fmt"
>> "os"
>> )
>>
>> type CatchExcept

[go-nuts] Re: Java to Go converter - 2

2022-04-07 Thread alex-coder
Thanks for the comments about generating code to handle exceptions. . Here 
it is a new version.
package main

import (
"fmt"
"os"
)

type CatchException struct{}

func main() {

var args []string = os.Args

var ce CatchException = CatchException{}
ce.CatchException_main(args)
}

/** generated method **/
func (catchException *CatchException) CatchException_main(args []string) {
defer func() {
if err := recover(); err != nil {
exc := err.(Exception)
switch exc.msg {
case "Exception":
fmt.Println("yes, I caught it")
default:
fmt.Println("No, something is not right")
}
}
fmt.Println("finally processing")
}()

({}).runme()
}

type ThrowException struct{}

func (throwException *ThrowException) runme() {
panic(Exception{"Exception"})
}

type Exception struct {
    msg string
}

понедельник, 4 апреля 2022 г. в 14:12:37 UTC+3, alex-coder: 

>
>
>
>
> *Another use case for automatically translating codewritten in Java to 
> Golang is Exception Handling.The next example is likely to be about 
> multithreading.Example in Java:*
> package com.builder.start.here;
>
> public class CatchException {
>
> public static void main(String[] args) {
> try {
> new ThrowException().runme();
> } catch (Exception e) {
> System.out.println("yes, I caught it");
> } finally {
> System.out.println("finally processing");
> }
>
> }
>
> }
>
> class ThrowException{
> public void runme() throws Exception{
> throw new Exception();
> }
> }
>
> *Converter gave out:*
>
> package main
>
> import (
> "fmt"
> "os"
> )
>
> type CatchException struct{}
>
>
> func main() {
>
> var args []string = os.Args
>
> var ce CatchException = CatchException{}
> ce.CatchException_main(args)
> }
>
> /** generated method **/
> func (catchException *CatchException) CatchException_main(args []string) {
> defer func() {
> if err := recover(); err != nil {
> str := err.(string)
> switch str {
> case "Exception":
> fmt.Println("yes, I caught it")
> default:
> fmt.Println("No, something is not right")
> }
> }
> fmt.Println("finally processing")
> }()
>
> ({}).runme()
> }
>
> type ThrowException struct{}
>
> func (throwException *ThrowException) runme() {
> panic("Exception")
> }
> воскресенье, 27 марта 2022 г. в 15:11:48 UTC+3, alex-coder: 
>
>> After several months of switching from Java to Golang, it seemed to me 
>> that
>> it would be interesting to make the translation of Java code into Golang 
>> automatically.
>> The text below shows what has been done so far.
>>
>> The work is not a prototype, but rather indicates the possibility of 
>> achieving a result.
>> Therefore, I deliberately simplify the development context of the 
>> Converter where it was 
>> possible. 
>>
>> At first it seemed important to me that between Java and Go there is a 
>> difference 
>> between the implementation of the Dynamic Dispatching, more precisely, 
>> there is no 
>> Dynamic Dispatching in Go. The applied solution in the current 
>> implementation 
>> looks not only ugly but even violates the several very important rules of 
>> the OO design, 
>> I'm not kidding here. But this option looks like that it will be working. 
>>
>> Onward I will provide the 4 code samples in Java, followed by the 
>> automatically 
>> generated Golang code and comments as needed. 
>>
>> *1. Of course, I started with the most popular program: "Hello World".*
>>
>> package main;
>>
>> public class HelloWorld {
>>   public static void main(  String[] args){
>> System.out.println("Hello World");
>>   }
>> }
>>
>> *Converter gave out:*
>>
>> package main
>>
>> import (
>> "fmt"
>> "os"
>> )
>>
>> type HelloWorld struct{}
>>
>> func main() {
>>
>> var args []string = os.Args
>>
>> var hw HelloWorld = HelloWorld{}
>> hw.HelloWorld_main(args)
>> }
>>
>> /** generated method **/
>> func (helloWorld *HelloWorld) HelloWo

[go-nuts] Re: Java to Go converter - 2

2022-04-04 Thread alex-coder




*Another use case for automatically translating codewritten in Java to 
Golang is Exception Handling.The next example is likely to be about 
multithreading.Example in Java:*
package com.builder.start.here;

public class CatchException {

public static void main(String[] args) {
try {
new ThrowException().runme();
} catch (Exception e) {
System.out.println("yes, I caught it");
} finally {
System.out.println("finally processing");
}

}

}

class ThrowException{
public void runme() throws Exception{
throw new Exception();
}
}

*Converter gave out:*

package main

import (
"fmt"
"os"
)

type CatchException struct{}

func main() {

var args []string = os.Args

var ce CatchException = CatchException{}
ce.CatchException_main(args)
}

/** generated method **/
func (catchException *CatchException) CatchException_main(args []string) {
defer func() {
if err := recover(); err != nil {
str := err.(string)
switch str {
case "Exception":
fmt.Println("yes, I caught it")
default:
fmt.Println("No, something is not right")
}
}
fmt.Println("finally processing")
}()

({}).runme()
}

type ThrowException struct{}

func (throwException *ThrowException) runme() {
    panic("Exception")
}
воскресенье, 27 марта 2022 г. в 15:11:48 UTC+3, alex-coder: 

> After several months of switching from Java to Golang, it seemed to me that
> it would be interesting to make the translation of Java code into Golang 
> automatically.
> The text below shows what has been done so far.
>
> The work is not a prototype, but rather indicates the possibility of 
> achieving a result.
> Therefore, I deliberately simplify the development context of the 
> Converter where it was 
> possible. 
>
> At first it seemed important to me that between Java and Go there is a 
> difference 
> between the implementation of the Dynamic Dispatching, more precisely, 
> there is no 
> Dynamic Dispatching in Go. The applied solution in the current 
> implementation 
> looks not only ugly but even violates the several very important rules of 
> the OO design, 
> I'm not kidding here. But this option looks like that it will be working. 
>
> Onward I will provide the 4 code samples in Java, followed by the 
> automatically 
> generated Golang code and comments as needed. 
>
> *1. Of course, I started with the most popular program: "Hello World".*
>
> package main;
>
> public class HelloWorld {
>   public static void main(  String[] args){
> System.out.println("Hello World");
>   }
> }
>
> *Converter gave out:*
>
> package main
>
> import (
> "fmt"
> "os"
> )
>
> type HelloWorld struct{}
>
> func main() {
>
> var args []string = os.Args
>
> var hw HelloWorld = HelloWorld{}
> hw.HelloWorld_main(args)
> }
>
> /** generated method **/
> func (helloWorld *HelloWorld) HelloWorld_main(args []string) {
> fmt.Println("Hello World")
> }
>
> *2. Next, it was interesting to deal with the problem of a simple 
> inheritance.*
>
> package main;
>
> public class TestInheritance {
>   public static void main(  String[] args){
> Inheritance inh=null;
> inh=new Second();
> inh.hello();
> inh=new Third();
> inh.hello();
>   }
> }
> public interface Inheritance {
>   public void hello();
> }
> class Second implements Inheritance {
>   public void hello(){
> System.out.println("Second");
>   }
> }
> class Third implements Inheritance {
>   public void hello(){
> System.out.println("Third");
>   }
> }
>  
> *Converter gave out:*
>
> package main
>
> import (
> "fmt"
> "os"
> )
>
> type TestInheritance struct{}
>
> func main() {
>
> var args []string = os.Args
>
> var ti TestInheritance = TestInheritance{}
> ti.TestInheritance_main(args)
> }
>
> /** generated method **/
> func (testInheritance *TestInheritance) TestInheritance_main(args 
> []string) {
>
> var inh Inheritance
> inh = AddressSecond(Second{})
> inh.hello()
> inh = AddressThird(Third{})
> inh.hello()
> }
>
> type Inheritance interface {
> hello()
> }
> type Second struct{}
>
> func (second *Second) hello() {
> fmt.Println("Second")
> }
>
> type Third s

[go-nuts] Java to Go converter - 2

2022-03-27 Thread alex-coder
After several months of switching from Java to Golang, it seemed to me that
it would be interesting to make the translation of Java code into Golang 
automatically.
The text below shows what has been done so far.

The work is not a prototype, but rather indicates the possibility of 
achieving a result.
Therefore, I deliberately simplify the development context of the Converter 
where it was 
possible. 

At first it seemed important to me that between Java and Go there is a 
difference 
between the implementation of the Dynamic Dispatching, more precisely, 
there is no 
Dynamic Dispatching in Go. The applied solution in the current 
implementation 
looks not only ugly but even violates the several very important rules of 
the OO design, 
I'm not kidding here. But this option looks like that it will be working. 

Onward I will provide the 4 code samples in Java, followed by the 
automatically 
generated Golang code and comments as needed. 

*1. Of course, I started with the most popular program: "Hello World".*

package main;

public class HelloWorld {
  public static void main(  String[] args){
System.out.println("Hello World");
  }
}

*Converter gave out:*

package main

import (
"fmt"
"os"
)

type HelloWorld struct{}

func main() {

var args []string = os.Args

var hw HelloWorld = HelloWorld{}
hw.HelloWorld_main(args)
}

/** generated method **/
func (helloWorld *HelloWorld) HelloWorld_main(args []string) {
fmt.Println("Hello World")
}

*2. Next, it was interesting to deal with the problem of a simple 
inheritance.*

package main;

public class TestInheritance {
  public static void main(  String[] args){
Inheritance inh=null;
inh=new Second();
inh.hello();
inh=new Third();
inh.hello();
  }
}
public interface Inheritance {
  public void hello();
}
class Second implements Inheritance {
  public void hello(){
System.out.println("Second");
  }
}
class Third implements Inheritance {
  public void hello(){
System.out.println("Third");
  }
}
 
*Converter gave out:*

package main

import (
"fmt"
"os"
)

type TestInheritance struct{}

func main() {

var args []string = os.Args

var ti TestInheritance = TestInheritance{}
ti.TestInheritance_main(args)
}

/** generated method **/
func (testInheritance *TestInheritance) TestInheritance_main(args []string) 
{

var inh Inheritance
inh = AddressSecond(Second{})
inh.hello()
inh = AddressThird(Third{})
inh.hello()
}

type Inheritance interface {
hello()
}
type Second struct{}

func (second *Second) hello() {
fmt.Println("Second")
}

type Third struct{}

func (third *Third) hello() {
fmt.Println("Third")
}

func AddressSecond(s Second) *Second { return  }
func AddressThird(t Third) *Third{ return  }


*3. In the following example, it is necessary to correctly definea 
common interface for the inheritance tree.*

package no.packeges;

public class TestExtension {
  public static void main(  String[] args){
TestExtension te=new TestExtension();
te.hello();
te=new Second();
te.hello();
te=new Third();
te.hello();
te=new Fourth();
te.hello();
  }
  public void hello(){
System.out.println("hello");
  }
}
class Second extends TestExtension {
  public void hello(){
System.out.println("Second");
  }
}
class Third extends TestExtension {
  public void hello(){
System.out.println("Third");
  }
}
class Fourth extends Third {
  public void hello(){
System.out.println("Fourth");
  }
}

*Converter gave out:*

package main

import (
"fmt"
"os"
)

type TestExtension struct{}

func main() {

var args []string = os.Args

var te TestExtension = TestExtension{}
te.TestExtension_main(args)
}
func (testExtension *TestExtension) hello() {
fmt.Println("hello")
}

/** generated method **/
func (testExtension *TestExtension) TestExtension_main(args []string) {

var te ITestExtension = AddressTestExtension(TestExtension{})
te.hello()
te = AddressSecond(Second{})
te.hello()
te = AddressThird(Third{})
te.hello()
te = AddressFourth(Fourth{})
te.hello()
}

type Second struct {
TestExtension
}

func (second *Second) hello() {
fmt.Println("Second")
}

type Third struct {
TestExtension
}

func (third *Third) hello() {
fmt.Println("Third")
}

type Fourth struct {
Third
}

func (fourth *Fourth) hello() {
fmt.Println("Fourth")
}

type ITestExtension interface { 
/** Generated Method */
hello()
}

func AddressSecond(s Second) *Second  { return  }
func AddressThird(t Third) *Third { return  }
func AddressTestExtension(t TestExtension) *TestExtension { return  }
func AddressFourth(f Fourth) *Fourth  { return  }





*4. Now the Dynamic Dispatching 

[go-nuts] Re: Java to Golang converter

2021-12-16 Thread alex-coder
The topic is very interesting, is anyone being worked on a subject ?
Thank you.

четверг, 11 мая 2017 г. в 21:19:13 UTC+3, dtr...@gmail.com: 

>
> Java has vast number of libraries.
>
> Good thing is Golang is catching up with its own style.
>
> There are cases though where there is no equivalent libraries ( PDF 
> reading / writing, TIFF reading writing, Office File formats)
>
> There were a few attempts for Java to Go conversions but not complete (if 
> ever can be complete).
>
> github.com/dglo/java2go (converter but not with UTF-8 capabilities)
>
> https://github.com/timob/javaparser (java parser)
>
> github.com/tinycedar/class-parser  (java class parser)
>
> github.com/tinylcy/SmallVM (Java VM interpreter)
>
> github.com/tinycedar/vanilla
>
> All of these projects show the need to read from Java.
>
> Is there any other project or effort to map java functions --> go or even 
> a decent converter?
>
> Any plans to make a decent converter from somebody?
>
>
>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/626dd8a3-9014-4dbc-b0df-24407de7198en%40googlegroups.com.


Re: [go-nuts] UML && Golang, part 2 ?

2021-11-15 Thread alex-coder
After all, I found that plantuml is more suitable for code visualization. 
If anyone is interested, you will find it there: https://plantuml.com/

Thank all for participation.

суббота, 13 ноября 2021 г. в 19:43:20 UTC+3, alex-coder: 

> Satyendra,
> >> https://github.com/ofabry/go-callvis
>
> very interesting, but looks like a little bit out of date.
>
> Thank you.
>
>
> воскресенье, 4 июля 2021 г. в 18:57:46 UTC+3, satyendra...@gmail.com: 
>
>> Alex you can try this.
>>
>> https://github.com/ofabry/go-callvis
>>
>> Thanks and regards,
>> Satyendra
>>
>> On Sun, Jul 4, 2021, 9:15 PM alex-coder  wrote:
>>
>>> Well, if there is a complex or not very complex system written in a 
>>> programming language,
>>> using uml helps faster understand both the system and the dependencies 
>>> and constractions in the code. 
>>> Especially if the system is unfamiliar.
>>>
>>> Right ? :-)
>>>
>>> воскресенье, 4 июля 2021 г. в 14:27:29 UTC+3, Jan Mercl: 
>>>
>>>> On Sun, Jul 4, 2021 at 1:16 PM alex-coder  wrote: 
>>>>
>>>> > But what do you use instead then ? 
>>>>
>>>> For what? 
>>>>
>>>> In case it's not obvious, I never touched UML and I don't really 
>>>> understand its utility. So I'm asking an honest question. Knowing the 
>>>> answer might help to possibly provide some answer to your question. 
>>>>
>>> -- 
>>> 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...@googlegroups.com.
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/golang-nuts/2f3b4c90-5180-4522-b29f-b8ca2ad4c492n%40googlegroups.com
>>>  
>>> <https://groups.google.com/d/msgid/golang-nuts/2f3b4c90-5180-4522-b29f-b8ca2ad4c492n%40googlegroups.com?utm_medium=email_source=footer>
>>> .
>>>
>>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/b4fc90df-40a8-486e-9dd6-bc29fdba3b22n%40googlegroups.com.


Re: [go-nuts] UML && Golang, part 2 ?

2021-11-13 Thread alex-coder
Satyendra,
>> https://github.com/ofabry/go-callvis

very interesting, but looks like a little bit out of date.

Thank you.


воскресенье, 4 июля 2021 г. в 18:57:46 UTC+3, satyendra...@gmail.com: 

> Alex you can try this.
>
> https://github.com/ofabry/go-callvis
>
> Thanks and regards,
> Satyendra
>
> On Sun, Jul 4, 2021, 9:15 PM alex-coder  wrote:
>
>> Well, if there is a complex or not very complex system written in a 
>> programming language,
>> using uml helps faster understand both the system and the dependencies 
>> and constractions in the code. 
>> Especially if the system is unfamiliar.
>>
>> Right ? :-)
>>
>> воскресенье, 4 июля 2021 г. в 14:27:29 UTC+3, Jan Mercl: 
>>
>>> On Sun, Jul 4, 2021 at 1:16 PM alex-coder  wrote: 
>>>
>>> > But what do you use instead then ? 
>>>
>>> For what? 
>>>
>>> In case it's not obvious, I never touched UML and I don't really 
>>> understand its utility. So I'm asking an honest question. Knowing the 
>>> answer might help to possibly provide some answer to your question. 
>>>
>> -- 
>> 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...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/golang-nuts/2f3b4c90-5180-4522-b29f-b8ca2ad4c492n%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/golang-nuts/2f3b4c90-5180-4522-b29f-b8ca2ad4c492n%40googlegroups.com?utm_medium=email_source=footer>
>> .
>>
>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/446d6d1e-8847-4fcf-a354-9351129eb804n%40googlegroups.com.


[go-nuts] Re: question about Profiling Go Programs sample.

2021-09-30 Thread alex-coder
Vladimir, one more question.
Does it mean that it is impossible to display recursive call in web by use 
pprof, it is necessary to use some additional tool, right ?

четверг, 30 сентября 2021 г. в 11:38:49 UTC+3, alex-coder: 

> a little bit more resources:
> golang pprof 实战 | Wolfogre's Blog 
> <https://blog.wolfogre.com/posts/go-ppof-practice/>
> it seems to be in Chinese (I may be wrong), but thanks to google.
> четверг, 30 сентября 2021 г. в 09:55:17 UTC+3, alex-coder: 
>
>> Hi
>> >>I think this is expected
>> you are experienced.
>>
>> >> Depending on what you're looking for,
>> firstly, I want to learn how to use pprof properly and secondly, 
>> I even could not imagine that it is not my mistake or not using tool 
>> properly..
>>
>>
>> thank you so much.:-)
>> среда, 29 сентября 2021 г. в 21:55:20 UTC+3, vlad...@varank.in: 
>>
>>> Hey there,
>>>
>>> > I took  runtime/cpuprof.go with  version 1.4, where cpuprof.go just 
>>> appeared with the same result. :-)
>>>
>>> I think this is expected.
>>> Go 1.4 was released in 2014 — several years after the original post 
>>> about pprof, had been published. In fact, Go 1.4 is the version where the 
>>> relevant part of the runtime's profiler was migrated from C to Go. In this 
>>> version the same constant, I pointed earlier, already presented in this 
>>> source code (note maxCPUProfStack=64).
>>>
>>> > Vladimir, is there any resource to read about current and probably 
>>> future of the go profiling?
>>>
>>> Depending on what you're looking for, there are quite a few materials I 
>>> could recommend:
>>> - the documentation for runtime/pprof and net/http/pprof packages [1]
>>> - the documentation for google/pprof tool [2]
>>> - Go wiki on performance [3]
>>> - Felix Geisendörfer's (DataDog) notes on Go profiling internals [4] (he 
>>> also gave several talks about the topic last summer).
>>>
>>> Hope that could help.
>>>
>>> [1]: https://pkg.go.dev/runtime/pprof, https://pkg.go.dev/net/http/pprof
>>> [2]: https://github.com/google/pprof/tree/master/doc
>>> [3]: https://github.com/golang/go/wiki/Performance
>>> [4]: https://github.com/DataDog/go-profiler-notes
>>> On Wednesday, September 29, 2021 at 1:59:10 PM UTC+2 alex-coder wrote:
>>>
>>>> Vladimir,
>>>>
>>>> I took  runtime 
>>>> <https://cs.opensource.google/go/go/+/refs/tags/go1.4:src/runtime/> 
>>>> <https://cs.opensource.google/go/go/+/refs/tags/go1.4:src/runtime/>/
>>>> cpuprof.go 
>>>> <https://cs.opensource.google/go/go/+/refs/tags/go1.4:src/runtime/cpuprof.go>
>>>>  with  version 
>>>> 1.4, where cpuprof.go just appeared with the same result. :-)
>>>> it should be something else.
>>>>
>>>> Regards.
>>>>
>>>> вторник, 28 сентября 2021 г. в 11:31:55 UTC+3, alex-coder: 
>>>>
>>>>> Ok, thank you.
>>>>> Vladimir, is there any resource to read about current and probably 
>>>>> future of the go profiling ?
>>>>> In fact it is not only very important but and very, very interesting.
>>>>>
>>>>> Thank you.
>>>>>
>>>>>
>>>>> вторник, 28 сентября 2021 г. в 06:38:31 UTC+3, vlad...@varank.in: 
>>>>>
>>>>>> Hello,
>>>>>>
>>>>>> I suspect this is due to how the current version of Go runtime's CPU 
>>>>>> profiler keeps only up to 64 items, when it builds the function's stack 
>>>>>> frame (refer to 
>>>>>> https://github.com/golang/go/blob/go1.17/src/runtime/cpuprof.go#L21) 
>>>>>> With that, the resulting profile misses the relationship between 
>>>>>> main.DFS 
>>>>>> and its parent function, thus it "hangs" beneath the root node now.
>>>>>>
>>>>>> Keep in mind that the original post is almost 10 year old now. Some 
>>>>>> other details might have changed as well.
>>>>>>
>>>>>> Cheers,
>>>>>> V.
>>>>>>
>>>>>> On Monday, September 27, 2021 at 11:03:53 AM UTC+2 alex-coder wrote:
>>>>>>
>>>>>>> Hi All,
>>>>>>>
>>>>>>> currently I walk through sample given there:
>>>>>>> Profiling Go Programs - go.dev <https://go.dev/blog/pprof>
>>>>>>>
>>>>>>> but when I came at the point where the user should enter web command 
>>>>>>> to the pprof
>>>>>>> I do not see that the function DFS call itself on a picture.
>>>>>>> Looks like I do use a proper version of the sample - go_pro, where 
>>>>>>> the recursion is present:
>>>>>>> multi-language-bench/src/havlak/go_pro at master · 
>>>>>>> hundt98847/multi-language-bench · GitHub 
>>>>>>> <https://github.com/hundt98847/multi-language-bench/tree/master/src/havlak/go_pro>
>>>>>>>
>>>>>>> So, what could be the reason that the picture is painted not 
>>>>>>> properly ?
>>>>>>>
>>>>>>> I use 1.17.1, windows 10.
>>>>>>>
>>>>>>> Thank you.
>>>>>>>
>>>>>>>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/6a418a3f-aaa8-4f8a-917a-89ef4d9b0360n%40googlegroups.com.


[go-nuts] Re: question about Profiling Go Programs sample.

2021-09-30 Thread alex-coder
a little bit more resources:
golang pprof 实战 | Wolfogre's Blog 
<https://blog.wolfogre.com/posts/go-ppof-practice/>
it seems to be in Chinese (I may be wrong), but thanks to google.
четверг, 30 сентября 2021 г. в 09:55:17 UTC+3, alex-coder: 

> Hi
> >>I think this is expected
> you are experienced.
>
> >> Depending on what you're looking for,
> firstly, I want to learn how to use pprof properly and secondly, 
> I even could not imagine that it is not my mistake or not using tool 
> properly..
>
>
> thank you so much.:-)
> среда, 29 сентября 2021 г. в 21:55:20 UTC+3, vlad...@varank.in: 
>
>> Hey there,
>>
>> > I took  runtime/cpuprof.go with  version 1.4, where cpuprof.go just 
>> appeared with the same result. :-)
>>
>> I think this is expected.
>> Go 1.4 was released in 2014 — several years after the original post about 
>> pprof, had been published. In fact, Go 1.4 is the version where the 
>> relevant part of the runtime's profiler was migrated from C to Go. In this 
>> version the same constant, I pointed earlier, already presented in this 
>> source code (note maxCPUProfStack=64).
>>
>> > Vladimir, is there any resource to read about current and probably 
>> future of the go profiling?
>>
>> Depending on what you're looking for, there are quite a few materials I 
>> could recommend:
>> - the documentation for runtime/pprof and net/http/pprof packages [1]
>> - the documentation for google/pprof tool [2]
>> - Go wiki on performance [3]
>> - Felix Geisendörfer's (DataDog) notes on Go profiling internals [4] (he 
>> also gave several talks about the topic last summer).
>>
>> Hope that could help.
>>
>> [1]: https://pkg.go.dev/runtime/pprof, https://pkg.go.dev/net/http/pprof
>> [2]: https://github.com/google/pprof/tree/master/doc
>> [3]: https://github.com/golang/go/wiki/Performance
>> [4]: https://github.com/DataDog/go-profiler-notes
>> On Wednesday, September 29, 2021 at 1:59:10 PM UTC+2 alex-coder wrote:
>>
>>> Vladimir,
>>>
>>> I took  runtime 
>>> <https://cs.opensource.google/go/go/+/refs/tags/go1.4:src/runtime/> 
>>> <https://cs.opensource.google/go/go/+/refs/tags/go1.4:src/runtime/>/
>>> cpuprof.go 
>>> <https://cs.opensource.google/go/go/+/refs/tags/go1.4:src/runtime/cpuprof.go>
>>>  with  version 
>>> 1.4, where cpuprof.go just appeared with the same result. :-)
>>> it should be something else.
>>>
>>> Regards.
>>>
>>> вторник, 28 сентября 2021 г. в 11:31:55 UTC+3, alex-coder: 
>>>
>>>> Ok, thank you.
>>>> Vladimir, is there any resource to read about current and probably 
>>>> future of the go profiling ?
>>>> In fact it is not only very important but and very, very interesting.
>>>>
>>>> Thank you.
>>>>
>>>>
>>>> вторник, 28 сентября 2021 г. в 06:38:31 UTC+3, vlad...@varank.in: 
>>>>
>>>>> Hello,
>>>>>
>>>>> I suspect this is due to how the current version of Go runtime's CPU 
>>>>> profiler keeps only up to 64 items, when it builds the function's stack 
>>>>> frame (refer to 
>>>>> https://github.com/golang/go/blob/go1.17/src/runtime/cpuprof.go#L21) 
>>>>> With that, the resulting profile misses the relationship between main.DFS 
>>>>> and its parent function, thus it "hangs" beneath the root node now.
>>>>>
>>>>> Keep in mind that the original post is almost 10 year old now. Some 
>>>>> other details might have changed as well.
>>>>>
>>>>> Cheers,
>>>>> V.
>>>>>
>>>>> On Monday, September 27, 2021 at 11:03:53 AM UTC+2 alex-coder wrote:
>>>>>
>>>>>> Hi All,
>>>>>>
>>>>>> currently I walk through sample given there:
>>>>>> Profiling Go Programs - go.dev <https://go.dev/blog/pprof>
>>>>>>
>>>>>> but when I came at the point where the user should enter web command 
>>>>>> to the pprof
>>>>>> I do not see that the function DFS call itself on a picture.
>>>>>> Looks like I do use a proper version of the sample - go_pro, where 
>>>>>> the recursion is present:
>>>>>> multi-language-bench/src/havlak/go_pro at master · 
>>>>>> hundt98847/multi-language-bench · GitHub 
>>>>>> <https://github.com/hundt98847/multi-language-bench/tree/master/src/havlak/go_pro>
>>>>>>
>>>>>> So, what could be the reason that the picture is painted not properly 
>>>>>> ?
>>>>>>
>>>>>> I use 1.17.1, windows 10.
>>>>>>
>>>>>> Thank you.
>>>>>>
>>>>>>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/bbb3129f-bfc4-401c-80dc-99c575889fe1n%40googlegroups.com.


[go-nuts] Re: question about Profiling Go Programs sample.

2021-09-30 Thread alex-coder
Hi
>>I think this is expected
you are experienced.

>> Depending on what you're looking for,
firstly, I want to learn how to use pprof properly and secondly, 
I even could not imagine that it is not my mistake or not using tool 
properly..


thank you so much.:-)
среда, 29 сентября 2021 г. в 21:55:20 UTC+3, vlad...@varank.in: 

> Hey there,
>
> > I took  runtime/cpuprof.go with  version 1.4, where cpuprof.go just 
> appeared with the same result. :-)
>
> I think this is expected.
> Go 1.4 was released in 2014 — several years after the original post about 
> pprof, had been published. In fact, Go 1.4 is the version where the 
> relevant part of the runtime's profiler was migrated from C to Go. In this 
> version the same constant, I pointed earlier, already presented in this 
> source code (note maxCPUProfStack=64).
>
> > Vladimir, is there any resource to read about current and probably 
> future of the go profiling?
>
> Depending on what you're looking for, there are quite a few materials I 
> could recommend:
> - the documentation for runtime/pprof and net/http/pprof packages [1]
> - the documentation for google/pprof tool [2]
> - Go wiki on performance [3]
> - Felix Geisendörfer's (DataDog) notes on Go profiling internals [4] (he 
> also gave several talks about the topic last summer).
>
> Hope that could help.
>
> [1]: https://pkg.go.dev/runtime/pprof, https://pkg.go.dev/net/http/pprof
> [2]: https://github.com/google/pprof/tree/master/doc
> [3]: https://github.com/golang/go/wiki/Performance
> [4]: https://github.com/DataDog/go-profiler-notes
> On Wednesday, September 29, 2021 at 1:59:10 PM UTC+2 alex-coder wrote:
>
>> Vladimir,
>>
>> I took  runtime 
>> <https://cs.opensource.google/go/go/+/refs/tags/go1.4:src/runtime/> 
>> <https://cs.opensource.google/go/go/+/refs/tags/go1.4:src/runtime/>/
>> cpuprof.go 
>> <https://cs.opensource.google/go/go/+/refs/tags/go1.4:src/runtime/cpuprof.go>
>>  with  version 
>> 1.4, where cpuprof.go just appeared with the same result. :-)
>> it should be something else.
>>
>> Regards.
>>
>> вторник, 28 сентября 2021 г. в 11:31:55 UTC+3, alex-coder: 
>>
>>> Ok, thank you.
>>> Vladimir, is there any resource to read about current and probably 
>>> future of the go profiling ?
>>> In fact it is not only very important but and very, very interesting.
>>>
>>> Thank you.
>>>
>>>
>>> вторник, 28 сентября 2021 г. в 06:38:31 UTC+3, vlad...@varank.in: 
>>>
>>>> Hello,
>>>>
>>>> I suspect this is due to how the current version of Go runtime's CPU 
>>>> profiler keeps only up to 64 items, when it builds the function's stack 
>>>> frame (refer to 
>>>> https://github.com/golang/go/blob/go1.17/src/runtime/cpuprof.go#L21) 
>>>> With that, the resulting profile misses the relationship between main.DFS 
>>>> and its parent function, thus it "hangs" beneath the root node now.
>>>>
>>>> Keep in mind that the original post is almost 10 year old now. Some 
>>>> other details might have changed as well.
>>>>
>>>> Cheers,
>>>> V.
>>>>
>>>> On Monday, September 27, 2021 at 11:03:53 AM UTC+2 alex-coder wrote:
>>>>
>>>>> Hi All,
>>>>>
>>>>> currently I walk through sample given there:
>>>>> Profiling Go Programs - go.dev <https://go.dev/blog/pprof>
>>>>>
>>>>> but when I came at the point where the user should enter web command 
>>>>> to the pprof
>>>>> I do not see that the function DFS call itself on a picture.
>>>>> Looks like I do use a proper version of the sample - go_pro, where the 
>>>>> recursion is present:
>>>>> multi-language-bench/src/havlak/go_pro at master · 
>>>>> hundt98847/multi-language-bench · GitHub 
>>>>> <https://github.com/hundt98847/multi-language-bench/tree/master/src/havlak/go_pro>
>>>>>
>>>>> So, what could be the reason that the picture is painted not properly ?
>>>>>
>>>>> I use 1.17.1, windows 10.
>>>>>
>>>>> Thank you.
>>>>>
>>>>>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/01eacc8e-b5e3-4ab4-9052-94767cfd54dbn%40googlegroups.com.


[go-nuts] Re: question about Profiling Go Programs sample.

2021-09-29 Thread alex-coder
Vladimir,

I took  runtime 
<https://cs.opensource.google/go/go/+/refs/tags/go1.4:src/runtime/> 
<https://cs.opensource.google/go/go/+/refs/tags/go1.4:src/runtime/>/
cpuprof.go 
<https://cs.opensource.google/go/go/+/refs/tags/go1.4:src/runtime/cpuprof.go> 
with  version 
1.4, where cpuprof.go just appeared with the same result. :-)
it should be something else.

Regards.

вторник, 28 сентября 2021 г. в 11:31:55 UTC+3, alex-coder: 

> Ok, thank you.
> Vladimir, is there any resource to read about current and probably future 
> of the go profiling ?
> In fact it is not only very important but and very, very interesting.
>
> Thank you.
>
>
> вторник, 28 сентября 2021 г. в 06:38:31 UTC+3, vlad...@varank.in: 
>
>> Hello,
>>
>> I suspect this is due to how the current version of Go runtime's CPU 
>> profiler keeps only up to 64 items, when it builds the function's stack 
>> frame (refer to 
>> https://github.com/golang/go/blob/go1.17/src/runtime/cpuprof.go#L21) 
>> With that, the resulting profile misses the relationship between main.DFS 
>> and its parent function, thus it "hangs" beneath the root node now.
>>
>> Keep in mind that the original post is almost 10 year old now. Some other 
>> details might have changed as well.
>>
>> Cheers,
>> V.
>>
>> On Monday, September 27, 2021 at 11:03:53 AM UTC+2 alex-coder wrote:
>>
>>> Hi All,
>>>
>>> currently I walk through sample given there:
>>> Profiling Go Programs - go.dev <https://go.dev/blog/pprof>
>>>
>>> but when I came at the point where the user should enter web command to 
>>> the pprof
>>> I do not see that the function DFS call itself on a picture.
>>> Looks like I do use a proper version of the sample - go_pro, where the 
>>> recursion is present:
>>> multi-language-bench/src/havlak/go_pro at master · 
>>> hundt98847/multi-language-bench · GitHub 
>>> <https://github.com/hundt98847/multi-language-bench/tree/master/src/havlak/go_pro>
>>>
>>> So, what could be the reason that the picture is painted not properly ?
>>>
>>> I use 1.17.1, windows 10.
>>>
>>> Thank you.
>>>
>>>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/83f33008-f35f-4642-855f-05d2e2ec016cn%40googlegroups.com.


[go-nuts] Re: question about Profiling Go Programs sample.

2021-09-28 Thread alex-coder
Ok, thank you.
Vladimir, is there any resource to read about current and probably future 
of the go profiling ?
In fact it is not only very important but and very, very interesting.

Thank you.


вторник, 28 сентября 2021 г. в 06:38:31 UTC+3, vlad...@varank.in: 

> Hello,
>
> I suspect this is due to how the current version of Go runtime's CPU 
> profiler keeps only up to 64 items, when it builds the function's stack 
> frame (refer to 
> https://github.com/golang/go/blob/go1.17/src/runtime/cpuprof.go#L21) With 
> that, the resulting profile misses the relationship between main.DFS and 
> its parent function, thus it "hangs" beneath the root node now.
>
> Keep in mind that the original post is almost 10 year old now. Some other 
> details might have changed as well.
>
> Cheers,
> V.
>
> On Monday, September 27, 2021 at 11:03:53 AM UTC+2 alex-coder wrote:
>
>> Hi All,
>>
>> currently I walk through sample given there:
>> Profiling Go Programs - go.dev <https://go.dev/blog/pprof>
>>
>> but when I came at the point where the user should enter web command to 
>> the pprof
>> I do not see that the function DFS call itself on a picture.
>> Looks like I do use a proper version of the sample - go_pro, where the 
>> recursion is present:
>> multi-language-bench/src/havlak/go_pro at master · 
>> hundt98847/multi-language-bench · GitHub 
>> <https://github.com/hundt98847/multi-language-bench/tree/master/src/havlak/go_pro>
>>
>> So, what could be the reason that the picture is painted not properly ?
>>
>> I use 1.17.1, windows 10.
>>
>> Thank you.
>>
>>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/efbbb5ce-0ec0-4d73-84c0-6cf71c68c368n%40googlegroups.com.


[go-nuts] question about Profiling Go Programs sample.

2021-09-27 Thread alex-coder
Hi All,

currently I walk through sample given there:
Profiling Go Programs - go.dev 

but when I came at the point where the user should enter web command to the 
pprof
I do not see that the function DFS call itself on a picture.
Looks like I do use a proper version of the sample - go_pro, where the 
recursion is present:
multi-language-bench/src/havlak/go_pro at master · 
hundt98847/multi-language-bench · GitHub 


So, what could be the reason that the picture is painted not properly ?

I use 1.17.1, windows 10.

Thank you.

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/7f516db7-e796-4329-8da4-a6b6f28197e6n%40googlegroups.com.


Re: [go-nuts] UML && Golang, part 2 ?

2021-07-04 Thread alex-coder
Well, if there is a complex or not very complex system written in a 
programming language,
using uml helps faster understand both the system and the dependencies and 
constractions in the code. 
Especially if the system is unfamiliar.

Right ? :-)

воскресенье, 4 июля 2021 г. в 14:27:29 UTC+3, Jan Mercl: 

> On Sun, Jul 4, 2021 at 1:16 PM alex-coder  wrote:
>
> > But what do you use instead then ?
>
> For what?
>
> In case it's not obvious, I never touched UML and I don't really
> understand its utility. So I'm asking an honest question. Knowing the
> answer might help to possibly provide some answer to your question.
>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/2f3b4c90-5180-4522-b29f-b8ca2ad4c492n%40googlegroups.com.


[go-nuts] UML && Golang, part 2 ?

2021-07-04 Thread alex-coder
Ok, folk, as I see UML is not very popular within the community. :-)
But what do you use instead then ?

Anyway it must be some tool to present the code as a picture.
The picture is worth a thousand words :-).

Thank you.

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/db5362fb-6365-4b88-9b56-98c88cd5cb62n%40googlegroups.com.


[go-nuts] UML && Golang

2021-06-25 Thread alex-coder
Hi All !

I can't find an IDE that has a conversion tool from Golang code to uml 
diagrams. 
I will be very grateful for the link to.
You see, the picture is worth a thousand words :-).

Thank you.

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/25b47822-0a80-4dcd-983b-00460b3b5e4an%40googlegroups.com.


Re: [go-nuts] Re: Design patterns. builder ?

2021-04-03 Thread alex-coder
Hi, 
thank you for  everyone!

The main point here is: "generally isn't needed", but sometimes structure 
does not come described properly in some kind of string representation. :-)
the pair Func / funchandler - just excellent ! 
But what about other GO-4 patterns, I mean "isn't needed in go" ?
Where take a look at ?

Thank you.

On Thursday, April 1, 2021 at 4:29:14 PM UTC+3 ren...@ix.netcom.com wrote:

> The Go protobufs impl uses the builder pattern. 
>
> On Apr 1, 2021, at 2:21 AM, Brian Candler  wrote:
>
> The builder pattern generally isn't needed in go, because go has flexible 
> struct literals where you can omit any members you don't want. 
>
>
> You can implement it if you like, but it just adds a layer of boilerplate:
> https://gist.github.com/vaskoz/10073335
>
> Some people are drawn to functional options instead:
> https://dave.cheney.net/2014/10/17/functional-options-for-friendly-apis
>
> https://www.calhoun.io/using-functional-options-instead-of-method-chaining-in-go/
>
> But if you look at the standard library as a source of inspiration and 
> good practice, complex configuration is typically done via structs.  See 
> for example http.Server 
>
> -- 
> 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...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/golang-nuts/39e38cd7-93ee-4084-89e4-a22bcd1baaa6n%40googlegroups.com
>  
> 
> .
>
>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/cd0d77b4-f86e-4244-8e60-70ee07b96ad4n%40googlegroups.com.


[go-nuts] Re: Design patterns. builder ?

2021-04-01 Thread alex-coder
I apologize for being so intrusive.
I will only provide links to educational resources, in case it would be 
interesting for anyone.
GitHub - AlexanderGrom/go-patterns: Design patterns in Golang 
<https://github.com/AlexanderGrom/go-patterns> (in russian)
Go Patterns · GitBook (tmrts.com) <http://tmrts.com/go-patterns/>
GitHub - PacktPublishing/Go-Design-Patterns-for-Real-World-Projects: Go: 
Design Patterns for Real-World Projects, by Packt 
<https://github.com/PacktPublishing/Go-Design-Patterns-for-Real-World-Projects>
Patrones de Diseño en Go (designpatternsingo.com) 
<http://www.designpatternsingo.com/> (in spanish)

Thank you.

On Wednesday, March 31, 2021 at 4:55:48 PM UTC+3 alex-coder wrote:

> Even not commercial but rather industrial. I have found at least 4 
> educational already.
>
> Thank you.
>
> On Wednesday, March 31, 2021 at 3:26:20 PM UTC+3 alex-coder wrote:
>
>> Hi All,
>>
>> I'm a novice to golang. 
>> looking for a commercial example of implementing the builder pattern
>> in the context of the absence of dynamic dispatching in golang.
>>
>> Thank you.
>>
>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/498d0122-7211-4d9a-9d90-4d833040e22fn%40googlegroups.com.


[go-nuts] Design patterns. builder ?

2021-03-31 Thread alex-coder
Hi All,

I'm a novice to golang. 
looking for a commercial example of implementing the builder pattern
in the context of the absence of dynamic dispatching in golang.

Thank you.

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/dc4ac823-ffae-470b-a09a-31cb65dea283n%40googlegroups.com.


Re: [go-nuts] No generic, part -2

2021-03-13 Thread alex-coder
Hello again.

Looks like I have the several problems. :-)
First one is my English, it seems my written explanations not properly 
describe my wishes.
Next one is that I have missed the already closed discussion and include my 
opinion in context
where it would be unnecessary.

So, of course, of course the initial point to include generic into GO was 
the customer wishes.
And moreover possible I should change my opinion after reading all the 
references provided. :-)

Thank all of you.

On Saturday, March 13, 2021 at 5:31:50 PM UTC+3 axel.wa...@googlemail.com 
wrote:

> I want to re-iterate: The discussion of whether or not generics will be 
> added to Go has been going on for more than a decade. All arguments from 
> all sides have gotten fair consideration. A decision was reached.
>
> You might not agree with that decision. But saying that "there are no 
> arguments" or that "arguments have been ignored" is simply and demonstrably 
> false. I understand that it can be difficult to accept that other qualified 
> people can come to different conclusions from you, based on the same 
> available data. But it's simply going to happen. So please be mindful of 
> how you communicate. And ideally, don't try to re-open this discussion with 
> the same arguments that have already been heard. It took enough time and 
> energy from everyone to reach a decision once.
>
> On Sat, Mar 13, 2021 at 3:19 PM Space A.  wrote:
>
>> HI Martin,
>>
>> as Jan already explained, you're not only writing code, you also reading 
>> it. And you have to understand what's written. At the same time you're not 
>> just coding in Go, you're using the whole ecosystem including libraries and 
>> tools. So the mantra "just don't use if you don't like'' does not work, 
>> every Go programmer will be forced to use generics, to read and at the end, 
>> to write that code. 
>>
>> Second question you may ask - yes it will be overused, in fact in the 
>> very first year everything will be flooded with bad code. Because it's a 
>> new toy and biggest change to the language in years, because it's a "smart" 
>> way of doing things (we are mature programmers, aren't we?), because "type 
>> safety" and "performance" and so on so forth. 
>>
>>
>>
>>
>>
>> сб, 13 мар. 2021 г. в 15:45, Martin Schnabel :
>>
>>> (sorry space a, i didn't reply to list)
>>>
>>> hi alex and space a.
>>>
>>> as far as i know there is no reason that anybody has to write code with 
>>> generics when they are available. therefor i really don't understand the 
>>> negative mails to this list.
>>>
>>> do you also want others not to use them? how would that help you? could 
>>> you please explain to me your personal gain if generics are not added to 
>>> go and not available to me and other users? many users have valid use 
>>> cases for generics and custom code generation to deal with them now.
>>>
>>> i personally never had a reason to use imaginary numbers in go, they are 
>>> however part of the language as literals and accompanied by special 
>>> built-ins. should i care, do you?
>>>
>>> please explain
>>>
>>> On 13.03.21 12:34, Space A. wrote:
>>> > There is no rationale. They decided, and they implemented. No one from 
>>> > Go team ever took the argument against it seriously because 
>>> "community" 
>>> > demands, blabla. And because Russ Cox with friends written an academic 
>>> > paper so this is now a question of pure science. Write your own and 
>>> they 
>>> > could listen. (No)
>>> > 
>>> > суббота, 13 марта 2021 г. в 10:07:44 UTC+3, alex-coder:
>>> > 
>>> > Hello,
>>> > 
>>> > Thank you for the answers.
>>> > Now I have something to read. :-)
>>> > 
>>> > So, sorry for my English.
>>> > Personally, I would add a dynamic dispatching into GO
>>> > and left language without generic in order to keep simplicity for 
>>> GO
>>> > and to make life of the applied programmers easier :-)
>>> > 
>>> > What I'm looking for is the rationale behind the technical decision
>>> > to understand why the sort of decision has been taken.
>>> > 
>>> > Thank you again for the answers.
>>> > 
>>> > On Saturday, March 13, 2021 at 7:15:06 AM UTC+3 Ian Lance Taylor 
>>> wrote:
>>> > 
>>> > On 

Re: [go-nuts] No generic, part -2

2021-03-12 Thread alex-coder
Hello,

Thank you for the answers.
Now I have something to read. :-)

So, sorry for my English.
Personally, I would add a dynamic dispatching into GO
and left language without generic in order to keep simplicity for GO
and to make life of the applied programmers easier :-)

What I'm looking for is the rationale behind the technical decision
to understand why the sort of decision has been taken.

Thank you again for the answers.

On Saturday, March 13, 2021 at 7:15:06 AM UTC+3 Ian Lance Taylor wrote:

> On Fri, Mar 12, 2021 at 7:31 AM alex-coder  wrote:
> >
> > Hello again,
> > I apologize for being so intrusive.
> > Where it is possible to read about the evaluations of labor and 
> complexity for
> > GO itself for different implementations to introduce generic in GO ?
>
> LIke others, I'm not quite sure what you are asking, but perhaps you
> want to look at
>
>
> https://go.googlesource.com/proposal/+/refs/heads/master/design/generics-implementation-stenciling.md
>
> https://go.googlesource.com/proposal/+/refs/heads/master/design/generics-implementation-dictionaries.md
>
> https://go.googlesource.com/proposal/+/refs/heads/master/design/generics-implementation-gcshape.md
>
> Ian
>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/f039428d-f87d-4668-9525-f662014abb79n%40googlegroups.com.


[go-nuts] No generic, part -2

2021-03-12 Thread alex-coder
Hello again, 
I apologize for being so intrusive. 
Where it is possible to read about the evaluations of labor and complexity 
for 
GO itself for different implementations to introduce generic in GO ?

Thank you.

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/64e6d441-3564-49ab-9f97-233eda3ea682n%40googlegroups.com.


Re: [go-nuts] no generic ?

2021-02-23 Thread alex-coder

>
> Hello,
>>
>> thank you very much for clarification.
>>>
>> I'm just a  beginner and come here to understand rationale behind the 
>>> decision.
>>
>>
>>> Thank you so much !
>>
>>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/4f2d149e-b110-4078-8b79-f56950c93626n%40googlegroups.com.


[go-nuts] no generic ?

2021-02-21 Thread alex-coder
Hi all !
I'm just a beginner in Golang and I see a discussion in regards to 
introduce generics into Go.
But is it possible to provide an example where it is impossible to use 
interface instead of generic ?
Thank you in advance.

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/e0139450-f753-4921-ba6f-fd0b252c525cn%40googlegroups.com.