New keyword for Golang

Let's imagine that Golang will get a new keyword __func(level)
that Go compiler will replace with a string package_name.func_name: line_number.
level is F | E | W | I (that means FATAL | ERROR | WARNING | INFO)

It could save time for good logging.

// an example
package myPackage

func myFunc() {
    ...
    fmt.Println(__func(I), "Everything is good")
    ...
    If err != nil {
        log.Fatalln(__func(F), err)
    }
    ...
}
**output**
INFO: myPackage.myFunc: 12. Everything is good
FATAL: myPackage.myFunc: 31. The system cannot find ... 

What do you think?

Why do you need keyword? https://play.golang.org/p/P6a_2E_H9HO

3 Likes

Hi Sean
Great solution!
There are no needs in a new keyword :slight_smile:
Maybe just to save execution time for huge logging.
Thanks a lot!

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.