I'm trying to "force" my Go
system to behave in a particular manner to make my "testing" easier.
I have the following code snippet:
func SendTokenProcessFromModel(process model.Process) (*SendTokenProcess, error) {
cdc := codec.New()
var msgSend bank.MsgSend
if err := cdc.UnmarshalJSON(process.RawMessage, &msgSend); err != nil {
return nil, fmt.Errorf("could not unmarshal a MsgSend: %w", err)
}
...
}
In which I would like to set the err
variable to true
to force my function to stop and, as consequence, the action to fail.
I have come across 2x approaches to set a variable whilst debugging.
golang/vscode-go #1173
Where they suggest that you set the variable using theVARIABLES
tab in the debugger.I cannot do this as the
err
variable from my above snippet isn't present... the only variables present are the 3x others, namely:cdc
,process
&msgSend
- assuming that ourBreakpoint
has been inserted at line "4":if err := cdc...
go-delve/delve #826
Where it is suggested to use thedlv
CLI and to perform a command such as that outlined below:
(dlv)
set err = "true"
Due to the debugging session being instantiated by VS Code I cant access the (dlv)
commands.
I did try typing it directly into the DEBUG CONSOLE
with no success, only error messages.
I'm not saying this can't be done, just that I don't know how should it be possible.
From option 1 they also nention the below:
err := "true"
But, again, not sure where, or how, to implement this.
Any help, guidance or support is appreciated as always.
Kind regards,
Ben