[英]Why doesn't my struct code work?
package app
type ConfigSet struct {
installed bool
}
import (
"fmt"
"html/template"
"net/http"
)
func init() {
config := ConfigSet{}
// -------------------------------------- //
// CONFIGURATION //
// -------------------------------------- //
// Change to "true" after configuration is done!
config.installed = false
// -------------------------------------- //
// END CONFIGURATION //
// -------------------------------------- //
http.HandleFunc("/", index)
http.HandleFunc("/index.php", index)
}
func index(w http.ResponseWriter, r *http.Request) {
if config.installed == false {
w.Header().Set("Location", "/install/")
return
}
}
I can't seem to figure out why this doesn't work. 我似乎无法弄清楚为什么这行不通。 The error I get is:
我得到的错误是:
2012/05/21 13:22:01 go-app-builder: Failed parsing input (1 error)
2012/05/21 13:22:01 /root/TravianGAE/app/app.go:7:1: expected declaration, found 'import'
I don't understand, am I supposed to declare anything there? 我不明白,我应该在那儿声明什么吗?
在type
之前,将import
放在第一位。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.