mirror of
https://github.com/jbranchaud/til
synced 2026-01-03 07:08:01 +00:00
Add Configure Max String Print Length For Delve as a Go TIL
This commit is contained in:
@@ -10,7 +10,7 @@ pairing with smart people at Hashrocket.
|
|||||||
|
|
||||||
For a steady stream of TILs, [sign up for my newsletter](https://crafty-builder-6996.ck.page/e169c61186).
|
For a steady stream of TILs, [sign up for my newsletter](https://crafty-builder-6996.ck.page/e169c61186).
|
||||||
|
|
||||||
_1556 TILs and counting..._
|
_1557 TILs and counting..._
|
||||||
|
|
||||||
See some of the other learning resources I work on:
|
See some of the other learning resources I work on:
|
||||||
- [Ruby Operator Lookup](https://www.visualmode.dev/ruby-operators)
|
- [Ruby Operator Lookup](https://www.visualmode.dev/ruby-operators)
|
||||||
@@ -411,6 +411,7 @@ See some of the other learning resources I work on:
|
|||||||
- [Build For A Specific OS And Architecture](go/build-for-a-specific-os-and-architecture.md)
|
- [Build For A Specific OS And Architecture](go/build-for-a-specific-os-and-architecture.md)
|
||||||
- [Check If Cobra Flag Was Set](go/check-if-cobra-flag-was-set.md)
|
- [Check If Cobra Flag Was Set](go/check-if-cobra-flag-was-set.md)
|
||||||
- [Combine Two Slices](go/combine-two-slices.md)
|
- [Combine Two Slices](go/combine-two-slices.md)
|
||||||
|
- [Configure Max String Print Length For Delve](go/configure-max-string-print-length-for-delve.md)
|
||||||
- [Connect To A SQLite Database](go/connect-to-a-sqlite-database.md)
|
- [Connect To A SQLite Database](go/connect-to-a-sqlite-database.md)
|
||||||
- [Create A Slice From An Array](go/create-a-slice-from-an-array.md)
|
- [Create A Slice From An Array](go/create-a-slice-from-an-array.md)
|
||||||
- [Detect If Stdin Comes From A Redirect](go/detect-if-stdin-comes-from-a-redirect.md)
|
- [Detect If Stdin Comes From A Redirect](go/detect-if-stdin-comes-from-a-redirect.md)
|
||||||
|
|||||||
29
go/configure-max-string-print-length-for-delve.md
Normal file
29
go/configure-max-string-print-length-for-delve.md
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
# Configure Max String Print Length For Delve
|
||||||
|
|
||||||
|
During a [Delve](https://github.com/go-delve/delve) debugging session, we can
|
||||||
|
print out the value of a given variable with the `print` command. Similarly, we
|
||||||
|
can see the values of all local variables with the `locals` command.
|
||||||
|
|
||||||
|
Whenever Delve is printing out strings and slices, it will truncate what it
|
||||||
|
displays to 64 characters (or items) by default.
|
||||||
|
|
||||||
|
```go
|
||||||
|
(dlv) print diagnostics.Solutions[0]
|
||||||
|
"295743861\n431865972\n876192543\n387459216\n612387495\n549216738\n7635...+25 more"
|
||||||
|
```
|
||||||
|
|
||||||
|
This can be overridden by [changing the `config` of
|
||||||
|
`max-string-len`](https://github.com/derekparker/delve/blob/237c5026f40e38d2dd6f62a7362de7b25b00c1c7/Documentation/cli/expr.md?plain=1#L59)
|
||||||
|
to something longer. In my case here, all I need are about 90 characters to
|
||||||
|
display my full string, so run `config max-string-len 90` from the `dlv`
|
||||||
|
session.
|
||||||
|
|
||||||
|
```go
|
||||||
|
(dlv) config max-string-len 90
|
||||||
|
(dlv) print diagnostics.Solutions[0]
|
||||||
|
"295743861\n431865972\n876192543\n387459216\n612387495\n549216738\n763524189\n928671354\n154938627"
|
||||||
|
```
|
||||||
|
|
||||||
|
Now I can see the entire string instead of the truncated version.
|
||||||
|
|
||||||
|
[source](https://stackoverflow.com/a/52416264/535590)
|
||||||
Reference in New Issue
Block a user