une 13, 2019 at 1:05:15 AM UTC-4, ThisEndUp wrote:
>
> All of a sudden, when trying to build programs that used to work, as
> recently as a couple of days ago, I'm getting
>
> main.go:6:2: cannot find package "text/template" in any of:
> C:\Go\src\text\template (from $G
All of a sudden, when trying to build programs that used to work, as
recently as a couple of days ago, I'm getting
main.go:6:2: cannot find package "text/template" in any of:
C:\Go\src\text\template (from $GOROOT)
D:\\Go\src\text\template (from $GOPATH)
I was trying this in a module, but
Oops, I left a few lines at the top of main.go out of the post: here's the
whole thing:
// main.go
package main
import (
"fmt"
"net/http"
)
func handleRoot(w http.ResponseWriter, r *http.Request) {
http.ServeFile(w, r, "webpages/main.html")
}
func main() {
http.HandleFunc("/",
Hi. Thanks for your explanation. It makes sense.
However, the "magic" I asked about was based on your first suggestion:
simply use
http.Handle("/", http.FileServer(http.Dir("webpages")))
As I said, it works if the file to be shown is index.html. My question: how
do I modify that in order to
I am thoroughly frustrated. I have a file named main.html that references a
css and a js file.
Here's the relevant portion.
This is in a subdirectory of my GOPATH/src, named learn/webpages, and the
css and js files are in subdirectories of that, i.e.,
day, 1 May 2019 15:11:55 UTC+1, ThisEndUp wrote:
>>
>> I'm new to Go and am in the design phase of a project that will display
>> live sensor data on a web page. The data are transferred via an MQTT
>> broker. I have done such things in the past using a websocket but wonde
I'm new to Go and am in the design phase of a project that will display
live sensor data on a web page. The data are transferred via an MQTT
broker. I have done such things in the past using a websocket but wonder if
a template would be a more appropriate method. Any thoughts?
Thanks.
--
You