gm

an extremely simple gemini browser/formatter
git clone git://bvnf.space/gm.git
Log | Files | Refs | LICENSE

commit 0cba7275e3671519dc9bed9de1c28142ff0a2f55
parent 76f31483b826f61e9ba05147572f6e7eae4eaea2
Author: phoebos <ben@bvnf.space>
Date:   Sat, 28 Aug 2021 17:42:36 +0100

pass a pointer to string to Prettify

Diffstat:
Mgemini.go | 3++-
Mgemtext.go | 7++++---
2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/gemini.go b/gemini.go @@ -79,5 +79,6 @@ func main() { fmt.Fprintf(os.Stderr, "error: %s\n", err.Error()) os.Exit(1) } - fmt.Println(Prettify(string(resp))) + s := string(resp) + fmt.Println(*Prettify(&s)) } diff --git a/gemtext.go b/gemtext.go @@ -5,8 +5,8 @@ import ( ) // Prettify formats gemtext nicely with escape sequences. -func Prettify(plain string) string { - lines := strings.Split(plain, "\n") +func Prettify(plain *string) *string { + lines := strings.Split(*plain, "\n") outlines := make([]string, 0, len(lines)) preform := false for _, line := range lines { @@ -55,5 +55,6 @@ func Prettify(plain string) string { outlines = append(outlines, outline) } - return strings.Join(outlines, "\n") + pretty := strings.Join(outlines, "\n") + return &pretty }