Post

GoLangGoLang

A
Athiq mohd

Posted on 24th April 2024|3748 views

0
votes

Golang Convert Error To String

How can I convert an error to a string?

Answers
P
sumana reddy

Posted on 24th April 2024

The error type contains an interface in Go

type error interface {

    Error() string

}

Thus, for an error err, you can call

err.Error()

 

Write your answer

STILL GOT QUERIES?

Get a Live FREE Demo
  • Explore the trending and niche courses and learning maps
  • Learn about tuition fee, payment plans, and scholarships
  • Get access to webinars and self-paced learning videos