示例#1
0
func GetProjectBrief(project_path string) ProjectBrief {
	var err error
	var data []byte
	var project_data Data
	name := utils.NameFromFile(project_path)
	data, err = ioutil.ReadFile(project_path)
	if err != nil {
		return ProjectBrief{name, "", false}
	}
	err = json.Unmarshal(data, &project_data)
	fmt.Println("%q", err)
	if err != nil {
		return ProjectBrief{name, "ERROR READING PROJECT", true}
	}
	return ProjectBrief{name, project_data.Description, true}
}
示例#2
0
func (g *GoautSession) GetProjects(active bool) string {
	var response []byte
	var err error
	list := NewValueList()
	if active == false {
		files, _ := ioutil.ReadDir(g.Conf.ProjectDir)
		for _, f := range files {
			if utils.ExtFromFile(f.Name()) == ".json" {
				list.Value = append(list.Value, utils.NameFromFile(f.Name()))
			}
		}
		response, err = json.MarshalIndent(list, "", "  ")
		if err == nil {
			return string(response)
		} else {
			return fmt.Sprintf("{ \"Success\": false, \"Message\": \"%s\" }", err)
		}
	}
	return string(response)
}