Integration with MSAL(Azure AD) and GoLang: undefined


I’m integrating my Go Gin app with Azure AD for the company, ref: , however, it failed in the beginning step.

I got "undefined: publicClientApp"in this line:

publicClientapp, err := public.New("client_id", public.WithAuthority(""))

Does anyone know why this happens?
Are there any successful examples for Go and AAD?

The official example is not clear and there are so many errors which quite confused me.


This seems to work just fine.

package main

import (


func main() {
    publicClientApp, err := public.New("client_id", public.WithAuthority(""))
    if err != nil {

You show the error message "undefined: publicClientApp" but you are declaring the client as publicClientapp. If you attempt to use publicClientApp afterwards, you will see that error, as it has not been defined. (Note the uppercase A).

Answered By – The Fool

Answer Checked By – Marilyn (GoLangFix Volunteer)

Leave a Reply

Your email address will not be published.