package models import ( "os" "path/filepath" ) // Public gobal variables var ( PublicDir string ImgURLPrefix string ) // SetPublicDir sets the public dir func SetPublicDir(s string) { PublicDir = s } // SetImgURLPrefix sets the img url prefix func SetImgURLPrefix(s string) { ImgURLPrefix = s } func imageURL(suffix string) string { imgFile := filepath.Join(PublicDir, "img", suffix) if _, err := os.Stat(imgFile); !os.IsNotExist(err) { return ImgURLPrefix + suffix } return "" }