0

I am working on a golang webproject. I am using "net/http" and "golang.org/x/net/websocket" packages

Here is a part of my code:

func handleHomePage(responseWriter http.ResponseWriter, request *http.Request)      {
    http.ServeFile(responseWriter, request, "index.html")
}

func main() {
    http.HandleFunc("/", handleHomePage)
}

As you can see, i am serving a file called index.html.

Here is my project architecture:

├── bin
│   └── main
├── index.html
├── pkg
│   └── darwin_amd64
│       └── golang.org
│           └── x
│               └── net
│                   └── websocket.a
└── src
    ├── golang.org
    │   └── x
    │       └── net
    │         .....
    └── main
        └── manager.go

I am compiling the project with:

go install main

It provide me a main binary file in bin folder but this binary file does not include index.html file.

How can i embed this html file in binary as a resource ?

Thanks

Bob5421
  • 7,757
  • 14
  • 81
  • 175

0 Answers0