0

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.

  • 2
    we can only guess without a [mre] -- Are you trying to load a pcre package which needs cgo, but have no C compiler installed? (and if you don't have a C compiler at all, you probably haven't installed libpcre++ either) – JimB Aug 25 '23 at 15:08

1 Answers1

1

Use this pkg : https://github.com/joho/godotenv.
this package (github.com/Valgard/godotenv) no longer used.

F.S
  • 98
  • 8