Re: [go-nuts] How does the go compiler treat initialized string variables?

2022-11-03 Thread Konstantin Khomoutov
On Tue, Nov 01, 2022 at 11:18:48AM -0700, Frank Jüdes wrote: > I have to write a program that should verify the content of > configuration-servers. It will need a lot of pre-initialized data to verify > the actual content of a server, so it has to initialize many strings. What > i know from

Re: [go-nuts] How does the go compiler treat initialized string variables?

2022-11-02 Thread jake...@gmail.com
Just to add a tidbit to what Jan said. The key here is that strings (type string) in Go are immutable, whereas strings ("char *" based types) in C are not. That is why the same string can be used again and again without ever needing to be copied, and why they can live in the text segment. On

Re: [go-nuts] How does the go compiler treat initialized string variables?

2022-11-01 Thread Frank Jüdes
Just had an idea: I printed the address of the initialized variable, and for comparison another variable that was created in the heap: Address of package variable: 0x818710 Address of Program variable: 0xc10028 Imho it is a safe assumption that the initialized data-structure is not located

Re: [go-nuts] How does the go compiler treat initialized string variables?

2022-11-01 Thread Frank Jüdes
Thank you very much for the answer! - It actually turns out that my structure is a bit more complex than i though. The test-cases themself are a structure of seven strings and one in64 which are organized as a test-case list into a map[string] and those lists are organized into groups also as

Re: [go-nuts] How does the go compiler treat initialized string variables?

2022-11-01 Thread Jan Mercl
On Tue, Nov 1, 2022, 20:36 Frank Jüdes wrote: > I have to write a program that should verify the content of > configuration-servers. It will need a lot of pre-initialized data to verify > the actual content of a server, so it has to initialize many strings. What > i know from other C-style

[go-nuts] How does the go compiler treat initialized string variables?

2022-11-01 Thread Frank Jüdes
I have to write a program that should verify the content of configuration-servers. It will need a lot of pre-initialized data to verify the actual content of a server, so it has to initialize many strings. What i know from other C-style languages is, that code like var MyString *string =