Original post

 package log

import (
        "context"
        "log"
        "math/rand"
        "net/http"
)

const requestIDKey = 42

func Println(ctx context.Context, msg string) {
        id, ok := ctx.Value(requestIDKey).(int64)
        if !ok {
                log.Println("could not find request ID in context")
                return
        }
        log.Printf("[%d] %s", id, msg)
}

func Decorate(f http.HandlerFunc) http.HandlerFunc {
        return func(w http.ResponseWriter, r *http.Request) {
                ctx := r.Context()
                id := rand.Int63()
                ctx = context.WithValue(ctx, requestIDKey, id)
                f(w, r.WithContext(ctx))
        }
}

Hi, I saw this code in this video: https://www.youtube.com/watch?v=LSzR0VEraWw

and I don’t understand how he can use Println and Decorate as a custom function name.
I am getting yellow underlines which says “exported function Println should have comment or be unexported”

I don’t understand what it means :frowning:

exported function Println should have comment or be unexported

means that either you should add a comment above your function to say what it does, like

// Println prints lines to console
func Println(...) {}

Or you should not have the function exported. Any function starting with a capital letter is exported.
This means the function can be used from outside your package.