[go-nuts] Please update the url of golang tour for Korean.

2020-08-19 Thread 박진수
Hi golang-nuts. 
 
I'm Jinsu, a Korean Go developer.
 
I've been reading "a tour of go" and tried reading its Korean version.
 
But as soon as I tried, I realized there was no available Korean go tour.
 
As you can see in this open issue(#709 tour: outdated tour version for korean 
translation), it's been so long since there wasn't any valid go-tour translated 
into Korea.
 
We guess the connected repository is https://github.com/atomaths/go-tour-kr but 
this repository has been so long(at least 6 years) since the owner didn't care 
it and we can't communicate with the owner.
 
So I'm trying to translate not only go-tour but also other documentations with 
creating a new cooperative organization(golang-ko) and a new repository.
 
If you can introduce our appspot url in the "go local" slide of the official 
go-tour(https://tour.golang.org/welcome/2).
 
The original deprecated appspot endpoint is https://go-tour-kr.appspot.com and 
our new appspot endpoint is https://go-tour-ko.appspot.com   (github: 
https://github.com/golang-ko/tour)
 
It's not a completely perfect version yet, but if you admit us as an official 
Korea go tour appspot, it would be very appreciated and hels our teammates keep 
do their best.
 
Thank you for reading my letter and I'll wait for your positive reply. Thank 
you again.

-- 
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/74a8dea34d843dec8e76a2a318643f%40cweb005.nm.nfra.io.


Re: [go-nuts] How to find repeated string?

2020-08-19 Thread Brian Candler
Here's one way to do adjacent repeats.
https://play.golang.org/p/402UEPtIkfw

But if you don't understand regular expressions, this could be done more 
simply by:

- finding the first occurrence of substr
- advancing the offset to just after the end of the match
- check if substr appears at the new position
- keep repeating until substr cannot be found any more

-- 
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/9f51a985-40be-40f1-9259-b4a53d54d6e3o%40googlegroups.com.


Re: [go-nuts] Re: Share GOMODCACHE between unix users

2020-08-19 Thread Marcin Romaszewicz
Yes, each user would populate their own module cache locally if using your
own proxy.

On Wed, Aug 19, 2020 at 10:04 AM wilk  wrote:

> On 19-08-2020, Marcin Romaszewicz wrote:
> > --71f06b05ad3dc9f8
> > Content-Type: text/plain; charset="UTF-8"
> >
> > I have many users building Go at my company, and instead of sharing the
> > module cache on the filesystem, a much better approach is to use a
> caching
> > module proxy, such as Athens (https://github.com/gomods/athens).
> >
> > See the documentation for the GOPROXY environment variable.
>
> With an alternate GOPROXY the GOMODCACHE of each users are still filled
> isn'it ?
>
> I've started an issue :
> https://github.com/golang/go/issues/40895
>
> --
> William Dodé
>
> --
> 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/rhjm1l%24b2d%241%40ciao.gmane.io
> .
>

-- 
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/CA%2Bv29LuS%2BAdCobh%2B_7HOkYG2t8fAaB1ROBzM1W1qpOyzftMpHQ%40mail.gmail.com.


Re: [go-nuts] more simple modules usage questions

2020-08-19 Thread Kurtis Rader
On Wed, Aug 19, 2020 at 12:12 PM 'K Richard Pixley' via golang-nuts <
golang-nuts@googlegroups.com> wrote:

> I have two local git repositories.  Both are go modules.  Call them,
> foo.com/one and foo.com/two.  Both have go.mod files declaring themselves
> to be, respectively, foo.com/one and foo.com/two based on go 1.15.
>
> I want to use a package from one in the other.
>
> import "foo.com/one/pkg/thing1"
>
> Short of publishing one of them on github, how do I do that?  Do I need to
> copy or symlink something?  Set some environment variables?
>

See the "replace" directive in
https://golang.org/cmd/go/#hdr-The_go_mod_file. Google "go mod replace
local path" and you'll find plenty of articles on this topic, such as
https://thewebivore.com/using-replace-in-go-mod-to-point-to-your-local-module/



-- 
Kurtis Rader
Caretaker of the exceptional canines Junior and Hank

-- 
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/CABx2%3DD8bXPLnZ8KKfqOL3zWVr7q%3DXdY7kz-zEiWQuZddd9CAtg%40mail.gmail.com.


[go-nuts] more simple modules usage questions

2020-08-19 Thread 'K Richard Pixley' via golang-nuts
I have two local git repositories.  Both are go modules.  Call them, 
foo.com/one and foo.com/two.  Both have go.mod files declaring 
themselves to be, respectively, foo.com/one and foo.com/two based on go 
1.15.


I want to use a package from one in the other.

   import "foo.com/one/pkg/thing1"

Short of publishing one of them on github, how do I do that?  Do I need 
to copy or symlink something?  Set some environment variables?


--
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/8a5d8a09-ca24-a8ff-2dc4-2c6cbbf58b0a%40juniper.net.


Re: [go-nuts] [generics] Type list syntax

2020-08-19 Thread Frederik Zipp
Ian Lance Taylor schrieb am Mittwoch, 19. August 2020 um 00:39:16 UTC+2:

> Yes, but here you are assigning the value struct{}{} to the type S. 
> That's not how type arguments work: type arguments are not assigned to 
> type parameters. Instead, the body of a generic function or type is 
> instantiated with the type argument. In a generic function, rather 
> than assigning a value struct{}{} to type S, we are replacing 
> instances of S in F with struct{}. But struct{} has no methods. So 
> can you call method M on an argument whose type is the type parameter? 
> Why or why not? 
>

Thanks for the explanation. 

Given this setup:

type S struct{}
func (s S) M() {}

func F1[T S](s T) { s.M() }
func F2[T struct{}](s T) {}

The instantiations would have to be:

F1[S] :: func(S)
F1[struct{}] :: func(S)

F2[struct{}] :: func(struct{})
F2[S] :: func(struct{})

Non-interface/non-"anyof" constraints would always be instantiated as 
themselves.
I can see that this might be surprising. Given that it doesn't add any 
value over normal function parameters it is probably not worth it.

-- 
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/9087e39e-65f0-49bc-8952-d50d6353d256n%40googlegroups.com.


[go-nuts] Re: Share GOMODCACHE between unix users

2020-08-19 Thread wilk
On 19-08-2020, Marcin Romaszewicz wrote:
> --71f06b05ad3dc9f8
> Content-Type: text/plain; charset="UTF-8"
>
> I have many users building Go at my company, and instead of sharing the
> module cache on the filesystem, a much better approach is to use a caching
> module proxy, such as Athens (https://github.com/gomods/athens).
>
> See the documentation for the GOPROXY environment variable.

With an alternate GOPROXY the GOMODCACHE of each users are still filled isn'it ?

I've started an issue :
https://github.com/golang/go/issues/40895

-- 
William Dodé

-- 
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/rhjm1l%24b2d%241%40ciao.gmane.io.


Re: [go-nuts] Share GOMODCACHE between unix users

2020-08-19 Thread Marcin Romaszewicz
I have many users building Go at my company, and instead of sharing the
module cache on the filesystem, a much better approach is to use a caching
module proxy, such as Athens (https://github.com/gomods/athens).

See the documentation for the GOPROXY environment variable.

-- Marcin

On Wed, Aug 19, 2020 at 9:39 AM wilk  wrote:

> Hi,
>
> I would like to have a global GOMODCACHE for all unix users, or a group of
> users to gain space and speed. I trust all the users.
>
> Using the same GOMODCACHE for all users doesn't works, the perms are only
> writable by the user running the build.
>
> Is there a workaround ? Could it be a feature ?
>
> Thanks
>
> --
> William
>
> --
> 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/rhim4i%24u2p%241%40ciao.gmane.io
> .
>

-- 
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/CA%2Bv29LttqD7CEDOpRVvEyqRwB7P9WbX9AoAW-mJOf3d4jPrBNQ%40mail.gmail.com.


[go-nuts] [CODE REVIEW] How to improve structure of Service and DAO Layers

2020-08-19 Thread Karan Singh


I am having a bit of difficulty in designing my Go code.

I'll try to demonstrate things with a very simple example of adding a new 
user to the database. I have 3 major components in this example: a handler, 
a service and a dao layer.

   1. 
   
   My Handler is only doing one thing: Calling a service.
   2. 
   
   The service is managing all the business logic and then calling the DAO 
   to interact with the database.
   3. 
   
   The DAO also has only responsibility: Storing in the database.
   
Also, just for context I am making GraphQL(gqlgen) requests to interact 
with my ElasticSearch(olivere/elastic) database, but that shouldn't affect 
the design too much.

MY CODE:

*https://play.golang.org/p/Wm9qubLJIGM*

I have read a lot of posts about using structs/interfaces to handle the 
service layer and DAO layer, but I am unable to implement the same in my 
usecase.

I don't have a background in Java/C# so I'm not well versed with OOP 
Principles but I did read a lot on MVC based on other answers.

My code works for now, but is it bad code?

I don't want to be passing parameters from one function to another. Is 
there a way to that with receivers on methods?

-- 
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/e5f9905b-5488-4aa5-b4d1-0adef6a0a75dn%40googlegroups.com.


[go-nuts] Share GOMODCACHE between unix users

2020-08-19 Thread wilk
Hi,

I would like to have a global GOMODCACHE for all unix users, or a group of
users to gain space and speed. I trust all the users.

Using the same GOMODCACHE for all users doesn't works, the perms are only
writable by the user running the build.

Is there a workaround ? Could it be a feature ?

Thanks

-- 
William

-- 
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/rhim4i%24u2p%241%40ciao.gmane.io.


Re: [go-nuts] New linker

2020-08-19 Thread 'Than McIntosh' via golang-nuts
To be clear, a fair amount of DWARF generation is already done in the
compiler (bulk of the line table, subprogram DIEs and inline DIEs, debug
ranges, etc).

As far as I know, there are no near term plans (at least within the
compiler+runtime team) to work on moving  other bits of DWARF generation to
the compiler from the linker, but I don't think there would be any
objection to someone else doing it.

Than

On Wed, Aug 19, 2020 at 11:21 AM Misha Gusarov  wrote:

> Hello Than,
>
> Are there plans to implement remaining pieces (I'm interested
> ing moving DWARF generation from linker to compiler) for 1.17, or is the
> project considered done for now?
>
> Best,
> Misha.
>
> On 18 Aug 2020, at 19:22, 'Than McIntosh' via golang-nuts wrote:
>
>
> To add to what Ian mentioned:
>
> Many of the measures outlined in https://golang.org/s/better-linker have
> been implemented at this point.  It was a multi-person effort, several
> members of the Go compiler/runtime team were involved (Jeremy, Cherry,
> Austin, and myself).
>
> The new indexed object file format and the improved deadcode
> implementation went into the tree in time to be included in Go 1.15.
>
> The additional changes in Go 1.16 include better streaming of data and
> relocations from object file to linker output, a rewrite of the pclntab
> code, support for content-addressable symbols, and more complete cleanup of
> the old legacy linker data structures (e.g. removal of sym.Symbol).
>
> Some things mentioned in the doc that didn't get implemented include
> moving to DWARF 5, and moving DWARF type generation from the linker to the
> compiler.
>
> HTH.
>
> Cheers, Than
>
> On Sun, Aug 16, 2020 at 12:46 AM Ian Lance Taylor  wrote:
>
>> On Sat, Aug 15, 2020 at 11:49 AM Amnon  wrote:
>> >
>> > What is the best place to read about the ongoing work on the new linker?
>> > With the Go 1.15 release, how far along are we with the plans?
>> > What has been achieved?
>> > And what is still to come?
>>
>> The work on the new linker is close to complete and has been merged
>> into tip for the future 1.16 release (although 1.16 won't be released
>> until next February).  The work is as described at
>> https://golang.org/s/better-linker.
>>
>> 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/CAOyqgcXEK_OWZxKOUieHBdoH4R0eyddu_cMf_p_udWSKgZsHdA%40mail.gmail.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/CA%2BUr55EHRz5O3HvdP6xwOZyrHWKJA-Oc%2B96nMOCnB%3DmzABTYqA%40mail.gmail.com
> 
> .
>
>
> --
> Misha
>

-- 
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/CA%2BUr55F9H3dk%2BV0asL8Mkjhx0ENWr%2BDBpoiW9ObhzTCaWNV3jw%40mail.gmail.com.


Re: [go-nuts] How to find repeated string?

2020-08-19 Thread Bakul Shah
On Aug 19, 2020, at 1:07 AM, 洪嘉鴻  wrote:
> 
> Hello everyone:
> I use golang with Win10. The version of golang which I'm using is go1.15.
> I want to find out the repeated string.
> For example, given a string which is "1134534534534534".
> I want the output string to be "345"
> I've tried to 
> Could anyone help me to solve this problem?

Your problem specification is ambiguous. For example, if you may be able
represent your input string as

...S^N... or 
...T^M... or 
...U...V..U..V..V.. where there are U occurs L times and V occurs K times.
Here S, T, U and V are substrings

Then any of the following possible answers may make sense:
1. S if len(S) > len(any T)
2. T if M > N (T occurs more frequently than any S)
3. U if len(U) > len(any V)
4. V if K > L (V occurs more frequently than any U)

Based on your example it appears you want 2. or 4. but can't be sure.
Specify the problem clearly & completely and the solution will usually
suggest itself!

-- 
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/62DA1B47-04CD-4B21-8F32-A0A907983757%40iitbombay.org.


Re: [go-nuts] New linker

2020-08-19 Thread Misha Gusarov

Hello Than,

Are there plans to implement remaining pieces (I'm interested
ing moving DWARF generation from linker to compiler) for 1.17, or is the
project considered done for now?

Best,
Misha.

On 18 Aug 2020, at 19:22, 'Than McIntosh' via golang-nuts wrote:


To add to what Ian mentioned:

Many of the measures outlined in https://golang.org/s/better-linker 
have

been implemented at this point.  It was a multi-person effort, several
members of the Go compiler/runtime team were involved (Jeremy, Cherry,
Austin, and myself).

The new indexed object file format and the improved deadcode 
implementation

went into the tree in time to be included in Go 1.15.

The additional changes in Go 1.16 include better streaming of data and
relocations from object file to linker output, a rewrite of the 
pclntab
code, support for content-addressable symbols, and more complete 
cleanup of

the old legacy linker data structures (e.g. removal of sym.Symbol).

Some things mentioned in the doc that didn't get implemented include 
moving

to DWARF 5, and moving DWARF type generation from the linker to the
compiler.

HTH.

Cheers, Than

On Sun, Aug 16, 2020 at 12:46 AM Ian Lance Taylor  
wrote:



On Sat, Aug 15, 2020 at 11:49 AM Amnon  wrote:


What is the best place to read about the ongoing work on the new 
linker?

With the Go 1.15 release, how far along are we with the plans?
What has been achieved?
And what is still to come?


The work on the new linker is close to complete and has been merged
into tip for the future 1.16 release (although 1.16 won't be released
until next February).  The work is as described at
https://golang.org/s/better-linker.

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/CAOyqgcXEK_OWZxKOUieHBdoH4R0eyddu_cMf_p_udWSKgZsHdA%40mail.gmail.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/CA%2BUr55EHRz5O3HvdP6xwOZyrHWKJA-Oc%2B96nMOCnB%3DmzABTYqA%40mail.gmail.com.




--
Misha

--
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/E5CF11E3-D05F-4D92-9B1C-867918AB5FF0%40ridge.co.


Re: [go-nuts] Re: best way to know executable version without running it

2020-08-19 Thread 'Axel Wagner' via golang-nuts
AIUI, the version number output by `consul version` is not specified by Go,
but by the consul source itself. As far as Go is concerned, it's just be a
string constant (or maybe even a dynamically assembled string from integer
constants or Anything really). As such, there is no really reliable way
to do what you want.

Go provides version information via the `go version -m` command pointed out
by others - as long as the binary is built using modules, which is the only
case *Go* knows anything about versions at all. If that doesn't work for
you, I don't think there is anything as far as Go is concerned.

On Wed, Aug 19, 2020, 10:36 thatipelli santhosh <
santhoshthatipelli...@gmail.com> wrote:

> Hi Guys
>
> Thank you for your response.
>
> Consul is go executable. I can get version using /bin/consul version
> command but I need to find the version using string search in executable
> file data.
>
>
> I noticed some pattern in executables
>
> 1.8.312345156252160h3100043191500ms781258760h94105:***@ => 1.8.3
>
> 1.8.212345156252160h3100043191500ms781258760h94105:***@ => 1.8.2
>
> 1.8.112345156252160h3100043191500ms781258760h94105:***@ => 1.8.1
>
> 1.8.012345156252160h3100043191500ms781258760h94105:***@
>
> 1.7.712345156252160h3100043191500ms781258760h94105:***@
>
> 1.7.612345156252160h3100043191500ms781258760h94105:***@
>
> 1.7.412345156252160h3100043191500ms781258760h94105:***@
>
> 1.7.312345156252160h3100043191500ms781258760h94105:***@
>
> 1.7.212345156252160h3100043191500ms781258760h94105:***@
>
> 1.6.812345156252160h3100043191500ms781258760h94105:***@
>
>
> the first 3 digits are version number in above strings which we found them
> executable but I don't find this string in all versions of consul
>
>
> So does go use any specific delimiter before or after adding version
> numbers in executable file (compiled file)?
>
> do you have any idea to get version number from go executable without
> executing it which is common for all?
>
> Note: Attached screenshot method is not working for all versions
>
>
>
> On Thu, Aug 13, 2020 at 6:35 PM Sathish VJ  wrote:
>
>> Maybe you are asking how to get build version information into the
>> executable.  If yes, then use -ldflags.
>> https://pmcgrath.net/include-version-information-in-golang-app
>>
>> On Thursday, 13 August 2020 at 15:12:36 UTC+5:30 seank...@gmail.com
>> wrote:
>>
>>> go version -m 
>>>
>>> On Thursday, August 13, 2020 at 10:30:56 AM UTC+2
>>> santhoshth...@gmail.com wrote:
>>>
 Hi All,

 What is best way to know a executable version without executing it
 through golang?

 I tried with reading the executable file through a scanner and matching
 every line with regex (like ngnix regx) but this is not working for all
 executables.

 Do you have any idea?

>>> --
>> 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/eac6fad2-edcf-47c2-8b0e-e1f2d2dd6d56n%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/CAN1Sb7wuBOxEFxO3KJnrDo9B6WuZcwCvnjsSHgZzKOMZ5OWO%3DQ%40mail.gmail.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/CAEkBMfEq_DBbRnNtwHioZ18fEYs1%3DjKZDaoTm3Ktp4cdhY8haQ%40mail.gmail.com.


Re: [go-nuts] How to find repeated string?

2020-08-19 Thread Michael Jones
Maybe this way?
https://play.golang.org/p/_OM4RvO83Cf

On Wed, Aug 19, 2020 at 4:04 AM Ian Davis  wrote:

> On Wed, 19 Aug 2020, at 12:02 PM, Ian Davis wrote:
>
>
>
> On Wed, 19 Aug 2020, at 11:54 AM, Brian Candler wrote:
>
> Or another thought - perhaps you are looking for *adjacent* repeats only?
>
> In that case strings.Count doesn't help because it counts all occurrences,
> not just adjacent ones.
>
>
> I suspect the OP is looking for the longest repeating substring.
>
>
> Hmm, that's not correct. Sorry for the noise.
>
> --
> 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/bbc89836-e955-45ed-aaa5-f06669128281%40www.fastmail.com
> 
> .
>


-- 

*Michael T. jonesmichael.jo...@gmail.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/CALoEmQwHU3trJrnLUFCqo7%2Bq0q8_K1EDsqv3oJ6-nfOP151kFQ%40mail.gmail.com.


Re: [go-nuts] How to find repeated string?

2020-08-19 Thread Ian Davis
On Wed, 19 Aug 2020, at 12:02 PM, Ian Davis wrote:
> 
> 
> On Wed, 19 Aug 2020, at 11:54 AM, Brian Candler wrote:
>> Or another thought - perhaps you are looking for *adjacent* repeats only?
>> 
>> In that case strings.Count doesn't help because it counts all occurrences, 
>> not just adjacent ones.
> 
> I suspect the OP is looking for the longest repeating substring.

Hmm, that's not correct. Sorry for the noise.

-- 
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/bbc89836-e955-45ed-aaa5-f06669128281%40www.fastmail.com.


Re: [go-nuts] How to find repeated string?

2020-08-19 Thread Ian Davis


On Wed, 19 Aug 2020, at 11:54 AM, Brian Candler wrote:
> Or another thought - perhaps you are looking for *adjacent* repeats only?
> 
> In that case strings.Count doesn't help because it counts all occurrences, 
> not just adjacent ones.

I suspect the OP is looking for the longest repeating substring.

-- 
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/7de9-dca1-483a-86ca-7695f59dd0f2%40www.fastmail.com.


Re: [go-nuts] How to find repeated string?

2020-08-19 Thread Brian Candler
Or another thought - perhaps you are looking for *adjacent* repeats only?

In that case strings.Count doesn't help because it counts all occurrences, 
not just adjacent ones.

-- 
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/466d74d0-ab8c-41bc-8622-3412a4229e6bo%40googlegroups.com.


Re: [go-nuts] How to find repeated string?

2020-08-19 Thread Brian Candler
On Wednesday, 19 August 2020 10:41:57 UTC+1, 洪嘉鴻 wrote:
>
> Hello!
> This  is the code which I'm trying.
> The generation of map is the candidates from the string s1.
> However, the answer should be "345", which the count is not the most.
>

Your program says that the string "345" occurs 4 times - which is correct.

However, it also says that there are other sequences which occur more times 
- e.g. "34" occurs 5 times.  And there are longer repeating patterns which 
occur fewer times, e.g. "3453" occurs 2 times.  These are all correct.

So you have to think: what is your reason that "345" should be selected as 
"the best" answer, given that there are other answers which are better in 
terms of number of repeats or length of sequence?

You could create a score which is the length of the string times the number 
of repeats - e.g. "345" length 3 x 4 occurrences = score 12:
https://play.golang.org/p/7npKJ5B5VZR

But then there are non-repeating sequences which score higher.  Do you want 
to exclude sequences with a repeat count of 1 ?
https://play.golang.org/p/_Dg6s4nMOgw

-- 
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/5f22cd5e-d333-4232-a55b-66616b51926bo%40googlegroups.com.


Re: [go-nuts] How to find repeated string?

2020-08-19 Thread 洪嘉鴻
Hello!
This  is the code which I'm trying.
The generation of map is the candidates from the string s1.
However, the answer should be "345", which the count is not the most.

Thanks for your replying.
Max


Jan Mercl於 2020年8月19日星期三 UTC+8下午4時31分09秒寫道:
>
> On Wed, Aug 19, 2020 at 10:07 AM 洪嘉鴻 > 
> wrote: 
>
> > Hello everyone: 
> > I use golang with Win10. The version of golang which I'm using is 
> go1.15. 
> > I want to find out the repeated string. 
> > For example, given a string which is "1134534534534534". 
> > I want the output string to be "345" 
> > I've tried to 
> > Could anyone help me to solve this problem? 
>
> It would be nice if you can show the code that you wrote in an attempt 
> to solve this problem. Someone may then point out where a mistake was 
> made and/or suggest a better solution. 
>

-- 
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/3da3891b-9bb7-4981-9262-03708aad1d7do%40googlegroups.com.


Re: [go-nuts] Re: best way to know executable version without running it

2020-08-19 Thread thatipelli santhosh
Hi Guys

Thank you for your response.

Consul is go executable. I can get version using /bin/consul version
command but I need to find the version using string search in executable
file data.


I noticed some pattern in executables

1.8.312345156252160h3100043191500ms781258760h94105:***@ => 1.8.3

1.8.212345156252160h3100043191500ms781258760h94105:***@ => 1.8.2

1.8.112345156252160h3100043191500ms781258760h94105:***@ => 1.8.1

1.8.012345156252160h3100043191500ms781258760h94105:***@

1.7.712345156252160h3100043191500ms781258760h94105:***@

1.7.612345156252160h3100043191500ms781258760h94105:***@

1.7.412345156252160h3100043191500ms781258760h94105:***@

1.7.312345156252160h3100043191500ms781258760h94105:***@

1.7.212345156252160h3100043191500ms781258760h94105:***@

1.6.812345156252160h3100043191500ms781258760h94105:***@


the first 3 digits are version number in above strings which we found them
executable but I don't find this string in all versions of consul


So does go use any specific delimiter before or after adding version
numbers in executable file (compiled file)?

do you have any idea to get version number from go executable without
executing it which is common for all?

Note: Attached screenshot method is not working for all versions



On Thu, Aug 13, 2020 at 6:35 PM Sathish VJ  wrote:

> Maybe you are asking how to get build version information into the
> executable.  If yes, then use -ldflags.
> https://pmcgrath.net/include-version-information-in-golang-app
>
> On Thursday, 13 August 2020 at 15:12:36 UTC+5:30 seank...@gmail.com wrote:
>
>> go version -m 
>>
>> On Thursday, August 13, 2020 at 10:30:56 AM UTC+2 santhoshth...@gmail.com
>> wrote:
>>
>>> Hi All,
>>>
>>> What is best way to know a executable version without executing it
>>> through golang?
>>>
>>> I tried with reading the executable file through a scanner and matching
>>> every line with regex (like ngnix regx) but this is not working for all
>>> executables.
>>>
>>> Do you have any idea?
>>>
>> --
> 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/eac6fad2-edcf-47c2-8b0e-e1f2d2dd6d56n%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/CAN1Sb7wuBOxEFxO3KJnrDo9B6WuZcwCvnjsSHgZzKOMZ5OWO%3DQ%40mail.gmail.com.


Re: [go-nuts] How to find repeated string?

2020-08-19 Thread Jan Mercl
On Wed, Aug 19, 2020 at 10:07 AM 洪嘉鴻  wrote:

> Hello everyone:
> I use golang with Win10. The version of golang which I'm using is go1.15.
> I want to find out the repeated string.
> For example, given a string which is "1134534534534534".
> I want the output string to be "345"
> I've tried to
> Could anyone help me to solve this problem?

It would be nice if you can show the code that you wrote in an attempt
to solve this problem. Someone may then point out where a mistake was
made and/or suggest a better solution.

-- 
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/CAA40n-UrU6o8xbnZNYtTFSHG12Yg8BT68_eEU4C3JoKK4bKCSw%40mail.gmail.com.


[go-nuts] How to find repeated string?

2020-08-19 Thread 洪嘉鴻
Hello everyone:
I use golang with Win10. The version of golang which I'm using is go1.15.
I want to find out the repeated string.
For example, given a string which is "1134534534534534".
I want the output string to be "345"
I've tried to 
Could anyone help me to solve this problem?

Any help is appreciated.
Thank you very much!
Max

-- 
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/94f77c6a-10fe-42a1-8ed9-ed63706b30e3o%40googlegroups.com.