Your question should have included more information such as the Go version.
Nonetheless, I don't see how Delve is able to resolve "myValueInt" in your
example. I modified your code to include non-const versions of the symbols:

package main


import "fmt"


const constValueStr = "abc"
const constValueInt = 12
const constValueFloat = 1.2


var varValueStr = "def"
var varValueInt = 13


func main() {
        fmt.Println(constValueStr, constValueInt, constValueFloat,
varValueStr, varValueInt)
}


I put that code in a file named "x.go" and compiled it with "go build
x.go". The "strings" command shows both "varValue" symbols but neither
"constValue" symbols:

elvish> strings - x | grep varValue
_main.varValueInt
_main.varValueStr
elvish> strings - x | grep constValue
Exception: grep exited with 1
  [tty 156]:1:15-29: strings - x | grep constValue


Delve is able to resolve three of the five symbols:

elvish> dlv exec x
Type 'help' for list of commands.
(dlv) print main.varValueInt
13
(dlv) print main.constValueInt
12
(dlv) print main.constValueFloat
Command failed: could not find symbol value for main
(dlv) print main.varValueStr
(unreadable could not read string at 0x100086f47 due to protocol error E08
during memory read for packet $m100086f47,3)
(dlv) print main.constValueStr
Command failed: could not find symbol value for main


It is not obvious how Delve is able to resolve "main.constValueInt" since
that string does not appear in the binary according to the "strings - x"
command. So I think the more interesting question is how Delve is able to
resolve the "main.constValueInt" symbol but not the two other const symbols.


On Thu, May 30, 2024 at 1:58 AM Benoît Marguerie <bmarg...@gmail.com> wrote:

> or, in a easier way, a full "copy/paste" example of code:
>
> package main
>
> import "fmt"
>
> const myValueStr = "try"
> const myValueInt = 12
>
> func main() {
> fmt.Println("Instruction only to put a breakpoint")
> }
>
>
> Le jeudi 30 mai 2024 à 10:53:50 UTC+2, Benoît Marguerie a écrit :
>
>> Of course!
>> The code can be really simple like this:
>>
>>
>> *const myValueStr = "try"const myValueInt = 12*
>>
>>
>>
>> *func DoSomething() {   fmt.Println("Instruction only to put a
>> breakpoint")}*
>>
>>
>> and the result with delve:
>>
>>
>>
>>
>>
>> *(dlv) print %v myValueInt12(dlv) print %v myValueStrCommand failed:
>> could not find symbol value for myValueStr*
>>
>> Benoit
>>
> --
> 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/c938f107-9bca-4b8e-a10c-f8deef396c87n%40googlegroups.com
> <https://groups.google.com/d/msgid/golang-nuts/c938f107-9bca-4b8e-a10c-f8deef396c87n%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>


-- 
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%3DD--TKEdowrJdOFT%3Dgz5gTPZPWyyf42pHwkb8Jv0GxNDXg%40mail.gmail.com.

Reply via email to