In this code of golang i needed to set my .env but i got this error in the running:
Error while building: github.com/Valgard/go-pcre: build constraints exclude all Go files in C:\Users\pc\go\pkg\mod\github.com!valgard\go-pcre@v0.0.0-20200510215507-235e400e25e9
the code is:
package main
import (
"fmt"
"log"
"github.com/Valgard/godotenv"
"github.com/gin-gonic/gin"
)
func init() {
err := godotenv.Load(".env")
if err != nil {
log.Fatalf("Error loading .env file")
}
}
func main() {
fmt.Println("Hello world")
r := gin.Default()
r.GET("/ping", func(c *gin.Context) {
c.JSON(200, gin.H{
"message": "pong",
})
})
r.Run()
}
i searched alot without any sol.
Use this pkg : https://github.com/joho/godotenv.
this package (github.com/Valgard/godotenv) no longer used.