Go run main.go run error

I am getting this error while running my project
# command-line-arguments
runtime.main_main·f: function main is undeclared in the main package


package main

import (

type Contact struct {
	Email   string
	Subject string
	Message string

func Main() {
	tmpl := template.Must(template.ParseFiles("form.html"))

	http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
		if r.Method != http.MethodPost {
			tmpl.Execute(w, nil)
		details := Contact{
			Email:   r.FormValue("email"),
			Subject: r.FormValue("subject"),
			Message: r.FormValue("message"),

		_ = details

		tmpl.Execute(w, struct{ succes bool }{true})
	http.ListenAndServe(":8080", nil)



<h1> Thanks we received the message</h1>
<h1> Contact</h1>
<form method="POST">
    <label>Email:</label><br />
    <input type="text" name="email"><br />
    <label>Subject: </label><br />
    <input type="text" name="Subject"><br />
    <label>Message:</label><br />
    <textarea name="message"></textarea>
    <input type="submit">

The main-function has to be called main(), not Main().

1 Like

ok thanks

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.