From 5577b371224db35ecfffbce0ec85e6d29e066d27 Mon Sep 17 00:00:00 2001 From: rwxrob Date: Tue, 1 Mar 2022 21:24:27 -0500 Subject: [PATCH] Add String to goprintasstring --- scripts/goprintasjson | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/scripts/goprintasjson b/scripts/goprintasjson index 237dc20..0da482a 100755 --- a/scripts/goprintasjson +++ b/scripts/goprintasjson @@ -6,18 +6,21 @@ echo " // ---------------------------- PrintAsJSON --------------------------- -func (s $name) MarshalJSON() ([]byte, error) { +func (s *$name) MarshalJSON() ([]byte, error) { buf := "" // TODO return []byte(buf),nil } // JSON implements PrintAsJSON multi-line, 2-space indent JSON output. -func (s $name) JSON() string {b,_ :=s.MarshalJSON();return string(b)} -func (s $name) JSON() string {b,_ :=json.Marshal(s);return string(b)} +func (s *$name) JSON() string {b,_ :=s.MarshalJSON();return string(b)} +func (s *$name) JSON() string {b,_ :=json.Marshal(s);return string(b)} + +// String implements PrintAsJSON and fmt.Stringer interface as JSON. +func (s $name) String() string {return s.JSON()} // Print implements PrintAsJSON. -func (s $name) Print() { fmt.Println(s.JSON()) } +func (s *$name) Print() { fmt.Println(s.JSON()) } // Log implements PrintAsJSON. func (s $name) Log() { log.Print(s.JSON()) }