package main import ( "ansi" "bytes" "errs/stack" "fmt" ) func printTrace (s stack.Trace) { lf := s.Frames() for i,f := range lf { fmt.Printf("%d file %s line %d %s\n",i,f.File,f.LineNumber,f.FuncName) } } func GenerateBinaryString() string { binaryString := "" for c := 0; c < 255; c++ { if ('a' <= byte(c) && byte(c) <= 'z') || ('A' <= byte(c) && byte(c) <= 'Z') || byte(c) == '@' { binaryString += "1" } else { binaryString += "0" } } return binaryString } type ( MiCustomErr struct { error ms string } ) func (c MiCustomErr) Message() string { return "esto es un custom werro" } /* func fm (b *bytes.Buffer, e error, l int) { b.WriteString("Link :"+e.(MiCustomErr).Link+"\n") } */ func (c MiCustomErr) Unwrap () error { return c.error } func main() { c1 := ansi.Code(0).SetStyle(ansi.StyleBold|ansi.StyleUnderline) fmt.Printf("%s TexTo con Atts %s\n",c1,c1.End()) c1 = c1.DelStyle(ansi.StyleUnderline) s:= fmt.Sprintf("%s TexTo con Atts %s\n",c1,c1.End()) fmt.Print(s) b := &bytes.Buffer{} w := ansi.NewNonEscapeWriter(b) w.Write([]byte(s)) fmt.Print(string(b.Bytes())) }