当前位置: 首页>>代码示例>>Golang>>正文


Golang strings.Title函数代码示例

本文整理汇总了Golang中strings.Title函数的典型用法代码示例。如果您正苦于以下问题:Golang Title函数的具体用法?Golang Title怎么用?Golang Title使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了Title函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: MakeStructInterface

//writes structInterface.go, which has a function that takes in *Rows,
//makes them into an array of []TableName structs, and encodes this
//array into JSON format
func MakeStructInterface() {
	//header, imports
	structInterface := "package structs\n"
	structInterface += "import (\n"
	structInterface += "\t\"github.com/jmoiron/sqlx\"\n"
	structInterface += "\t\"encoding/json\"\n"
	structInterface += "\t\"net/http\"\n"
	structInterface += ")\n"

	//makes a function for each object
	tableList := sqlParser.GetTableNames()
	for _, table := range tableList {
		//function declaration
		structInterface += "func EncodeStruct" + strings.Title(table) + "(rows *sqlx.Rows, w http.ResponseWriter) {\n" //make new array
		structInterface += "\tsa := make([]" + strings.Title(table) + ", 0)\n"
		//make new instance
		structInterface += "\tt := " + strings.Title(table) + "{}\n\n"
		//loops through all columns and translates to JSON
		structInterface += "\tfor rows.Next() {\n"
		structInterface += "\t\t rows.StructScan(&t)\n"
		structInterface += "\t\t sa = append(sa, t)\n"
		structInterface += "\t}\n\n"
		structInterface += "\tenc := json.NewEncoder(w)\n"
		structInterface += "\tenc.Encode(sa)\n"
		structInterface += "}\n"
	}

	//writes in relation to home directory
	structBuilder.WriteFile(structInterface, "./structs/structInterface.go")
}
开发者ID:knutsel,项目名称:GoTO,代码行数:33,代码来源:structGenerator.go

示例2: List

func (this *ContestController) List(w http.ResponseWriter, r *http.Request) {
	class.Logger.Debug("Contest List")
	this.Init(w, r)

	args := this.ParseURL(r.URL.String())

	Type := args["type"]
	CModel := model.ContestModel{}
	conetestList, err := CModel.List(args)
	if err != nil {
		http.Error(w, err.Error(), 500)
		return
	}

	this.Data["Contest"] = conetestList
	this.Data["Time"] = this.GetTime()
	this.Data["Type"] = Type
	this.Data["Title"] = strings.Title(Type) + " List"
	this.Data["Is"+strings.Title(Type)] = true
	this.Data["Privilege"] = this.Privilege
	err = this.Execute(w, "view/layout.tpl", "view/contest_list.tpl")
	if err != nil {
		class.Logger.Debug(err)
		http.Error(w, "tpl error", 500)
		return
	}
}
开发者ID:netyum,项目名称:GoOnlineJudge,代码行数:27,代码来源:contest.go

示例3: main

func main() {
	modName, err := cli.GetModuleName()
	if err != nil {
		log.Fatalf(err.Error())
	}

	app, err := cli.NewApp(
		"0.1.0",
		"Mesosphere",
		fmt.Sprintf("Deploy and manage %s clusters", strings.Title(modName)))
	if err != nil {
		log.Fatalf(err.Error())
	}

	handleBrokerSection(app)
	handleTopicSection(app)
	cli.HandleCommonArgs(
		app,
		modName,
		fmt.Sprintf("%s DC/OS CLI Module", strings.Title(modName)),
		[]string{"address", "dns"})

	// Omit modname:
	kingpin.MustParse(app.Parse(os.Args[2:]))
}
开发者ID:mesosphere,项目名称:dcos-kafka-service,代码行数:25,代码来源:main.go

示例4: parseFolder

func parseFolder(filepath string) (EnumType, error) {
	files, err := ioutil.ReadDir(filepath)
	if err != nil {
		return EnumType{}, err
	}
	enumCases := []EnumCase{}
	enumTypes := []EnumType{}
	for _, f := range files {
		if strings.HasSuffix(f.Name(), "imageset") {
			rawValue := strings.Split(f.Name(), ".")[0]
			name := strings.Title(rawValue)
			name = strings.Replace(name, "_", "__", -1)
			name = strings.Replace(name, "-", "_", -1)
			enum := EnumCase{name, rawValue}
			enumCases = append(enumCases, enum)
		} else if !strings.Contains(f.Name(), ".") {
			folderName := path.Join(filepath, f.Name())
			enumType, err := parseFolder(folderName)
			if err != nil {
				return EnumType{}, err
			}
			enumTypes = append(enumTypes, enumType)
		}
	}
	_, file := path.Split(filepath)
	name := strings.Title(file)
	return EnumType{name, enumCases, enumTypes}, nil
}
开发者ID:jflinter,项目名称:Resourceful,代码行数:28,代码来源:resourceful.go

示例5: generateWhere

func generateWhere(t *models.Table, adapter string) (string, error) {
	placeholder := getPlaceholder(adapter)
	title := strings.Title(t.Name)
	firstChar := strings.ToLower(string(t.Name[0]))
	funcPlaceholderText := FormatFunction(title, "Where", "column string, arg interface{}", fmt.Sprintf("([]*%s, error)", title))
	queryText := `"select * from %s where %s = %s;"`
	if placeholder == "?" {
		queryText = fmt.Sprintf(queryText, t.Name, placeholder, placeholder)
	} else {
		queryText = fmt.Sprintf(queryText, t.Name, placeholder, "$2")
	}
	typeName := inflector.Singularize(strings.Title(t.Name))
	srcText := fmt.Sprintf(`	%s := make([]*%s, 0)
	rows, err := db.Queryx(%s, column, arg)
	if err != nil {
		return "", err
	}
	for rows.Next() {
			%s := &%s{}
			err = rows.StructScan(%s)
			if err != nil {
				return nil, err
			}
			%s = append(%s, %s)
		}
	return %s, nil`, firstChar+"s", typeName, queryText, firstChar, typeName, firstChar, firstChar+"s", firstChar+"s", firstChar, firstChar+"s")

	functionText := fmt.Sprintf(funcPlaceholderText, srcText)
	return functionText, nil
}
开发者ID:alistanis,项目名称:stg,代码行数:30,代码来源:generators.go

示例6: printjava

func printjava(dir string, apiset *parser.APISet, javapackage string) {
	if javapackage == "" {
		die(errors.New("must use -java_package=com.qortex.android to give java package"))
	}

	filedir := filepath.Join(dir, strings.Replace(javapackage, ".", "/", -1))
	err1 := os.MkdirAll(filedir, 0755)
	dieIf(err1)
	tpl := codeTemplate()

	for _, dataobj := range apiset.DataObjects {
		writeSingleJavaFile(tpl, filedir, javapackage, "java/dataobject", dataobj.Name, dataobj)
	}

	for _, inf := range apiset.Interfaces {
		data := make(map[string]interface{})
		data["Prefix"] = apiset.Prefix
		data["Interface"] = inf
		data["PkgName"] = strings.Title(apiset.Name)
		writeSingleJavaFile(tpl, filedir, javapackage, "java/interface", inf.Name, data)
	}
	writeSingleJavaFile(tpl, filedir, javapackage, "java/remote_error", "RemoteError", nil)
	writeSingleJavaFile(tpl, filedir, javapackage, "java/base64", "Base64", nil)

	writeSingleJavaFile(tpl, filedir, javapackage, "java/packageclass", strings.Title(apiset.Name), apiset)
}
开发者ID:gitter-badger,项目名称:hypermusk,代码行数:26,代码来源:main.go

示例7: resolveName

func (n *node) resolveName(base, name string, file *node) {
	if na := nameAnnotation(n.Annotations()); na != "" {
		name = na
	}
	if base != "" {
		n.name = base + strings.Title(name)
	} else {
		n.name = strings.Title(name)
	}

	n.pkg = file.pkg
	n.imp = file.imp

	if n.Which() != caps.NODE_STRUCT || !n.Struct().IsGroup() {
		file.nodes = append(file.nodes, n)
	}

	for _, nn := range n.NestedNodes().ToArray() {
		if ni := g_nodes[nn.Id()]; ni != nil {
			ni.resolveName(n.name, nn.Name(), file)
		}
	}

	if n.Which() == caps.NODE_STRUCT {
		for _, f := range n.Struct().Fields().ToArray() {
			if f.Which() == caps.FIELD_GROUP {
				gname := f.Name()
				if na := nameAnnotation(f.Annotations()); na != "" {
					gname = na
				}
				findNode(f.Group().TypeId()).resolveName(n.name, gname, file)
			}
		}
	}
}
开发者ID:tpukep,项目名称:caps,代码行数:35,代码来源:capnpc-pgo.go

示例8: formatProcName

// format Nim proc name from complete URI
func formatProcName(fullURI string) string {
	// remove leading `/`
	fullURI = fullURI[1:]

	// When meet `/{`
	// - replace it with `By`
	// - make uppercase the first char after `/{`
	spl := strings.Split(fullURI, "/{")
	tmp := []string{}
	for i, v := range spl {
		if i != 0 {
			v = strings.Title(v)
		}
		tmp = append(tmp, v)
	}
	name := strings.Join(tmp, "By")

	// when meet `/`
	// - make uppercase the first char after `/`
	// - remove the `/`
	spl = strings.Split(name, "/")
	tmp = []string{}
	for i, v := range spl {
		if i != 0 {
			v = strings.Title(v)
		}
		tmp = append(tmp, v)
	}

	return strings.Join(tmp, "")
}
开发者ID:Jumpscale,项目名称:go-raml,代码行数:32,代码来源:method.go

示例9: exception

func exception(name string) string {
	if strings.HasSuffix(name, "Exception") {
		return strings.Title(name)
	}

	return strings.Title(name) + "Exception"
}
开发者ID:gsrpc,项目名称:gsrpc,代码行数:7,代码来源:codegen.go

示例10: adminHandler

func adminHandler(w http.ResponseWriter, r *http.Request) {
	//权限判断
	cookie, err := r.Cookie("admin_name")
	if err != nil || cookie.Value == "" {
		http.Redirect(w, r, "/login/index", http.StatusFound)
	}

	//路由
	pathInfo := strings.Trim(r.URL.Path, "/")
	parts := strings.Split(pathInfo, "/")
	var action = ""
	if len(parts) > 1 {
		action = strings.Title(parts[1]) + "Action"
	}

	fmt.Printf("path%s %v\n", "adminHandler", pathInfo)
	login := &controller.AdminController{}
	controller := reflect.ValueOf(login)
	method := controller.MethodByName(action)
	if !method.IsValid() {
		method = controller.MethodByName(strings.Title("index") + "Action")
	}
	requestValue := reflect.ValueOf(r)
	responseValue := reflect.ValueOf(w)
	method.Call([]reflect.Value{responseValue, requestValue})

}
开发者ID:yylover,项目名称:programe,代码行数:27,代码来源:route.go

示例11: IsPrivateSignal

func IsPrivateSignal(f *parser.Function) bool {

	var fData string

	switch runtime.GOOS {
	case "darwin":
		fData = utils.Load(fmt.Sprintf("/usr/local/Qt5.5.1/5.5/clang_64/lib/%v.framework/Versions/5/Headers/%v", strings.Title(parser.ClassMap[f.Class()].DocModule), filepath.Base(f.Filepath)))

	case "windows":
		fData = utils.Load(fmt.Sprintf("C:\\Qt\\Qt5.5.1\\5.5\\mingw492_32\\include\\%v\\%v", strings.Title(parser.ClassMap[f.Class()].DocModule), filepath.Base(f.Filepath)))

	case "linux":
		switch runtime.GOARCH {
		case "amd64":
			{
				fData = utils.Load(fmt.Sprintf("/usr/local/Qt5.5.1/5.5/gcc_64/include/%v/%v", strings.Title(parser.ClassMap[f.Class()].DocModule), filepath.Base(f.Filepath)))
			}
		case "386":
			{
				fData = utils.Load(fmt.Sprintf("/usr/local/Qt5.5.1/5.5/gcc/include/%v/%v", strings.Title(parser.ClassMap[f.Class()].DocModule), filepath.Base(f.Filepath)))
			}
		}
	}

	if fData != "" {
		return strings.Contains(strings.Split(strings.Split(fData, f.Name+"(")[1], ")")[0], "QPrivateSignal")
	} else {
		fmt.Println("converter.IsPrivateSignal", f.Class())
	}

	return false
}
开发者ID:mouse225,项目名称:qt,代码行数:32,代码来源:body_input.go

示例12: FullName

func (f *Function) FullName() string {
	var r string
	if f.Receiver != nil {
		r = f.Receiver.Type.Value
	}
	return strings.Title(r) + strings.Title(f.Name)
}
开发者ID:cweill,项目名称:gotests,代码行数:7,代码来源:models.go

示例13: parseStats

func (m DockerPlugin) parseStats(stats *map[string]interface{}, name string, result *docker.Stats) error {
	(*stats)["docker.cpuacct."+name+".user"] = (*result).CPUStats.CPUUsage.UsageInUsermode
	(*stats)["docker.cpuacct."+name+".system"] = (*result).CPUStats.CPUUsage.UsageInKernelmode
	(*stats)["docker.memory."+name+".cache"] = (*result).MemoryStats.Stats.TotalCache
	(*stats)["docker.memory."+name+".rss"] = (*result).MemoryStats.Stats.TotalRss
	fields := []string{"read", "write", "sync", "async"}
	for _, field := range fields {
		for _, s := range (*result).BlkioStats.IOQueueRecursive {
			if s.Op == strings.Title(field) {
				(*stats)["docker.blkio.io_queued."+name+"."+field] = s.Value
			}
		}
		for _, s := range (*result).BlkioStats.IOServicedRecursive {
			if s.Op == strings.Title(field) {
				(*stats)["docker.blkio.io_serviced."+name+"."+field] = s.Value
			}
		}
		for _, s := range (*result).BlkioStats.IOServiceBytesRecursive {
			if s.Op == strings.Title(field) {
				(*stats)["docker.blkio.io_service_bytes."+name+"."+field] = s.Value
			}
		}
	}
	return nil
}
开发者ID:y-kuno,项目名称:mackerel-agent-plugins,代码行数:25,代码来源:docker.go

示例14: main

func main() {
	fmt.Print("// run\n\n")
	fmt.Print("// THIS FILE IS AUTO-GENERATED\n\n")
	fmt.Print("package main\n\n")
	fmt.Println(`import "fmt"`)

	types := []string{
		"int", "int8", "int16", "int32", "int64",
		"uint", "uint8", "uint16", "uint32", "uint64",
		"float32", "float64"}
	tocall := make([]string, 0, 32*len(types))
	for i := 1; i <= 32; i++ {
		for _, typ := range types {
			src := template
			src = strings.Replace(src, "NNN", fmt.Sprint(i), -1)
			src = strings.Replace(src, "TTT", strings.Title(typ), -1)
			src = strings.Replace(src, "ttt", typ, -1)
			src = strings.Replace(src, "ONES", "1"+strings.Repeat(", 1", i-1), -1)
			src = strings.Replace(src, "TWOS", "2"+strings.Repeat(", 2", i-1), -1)
			fmt.Print(src)
			tocall = append(tocall, fmt.Sprintf("CheckEq%d_%s", i, strings.Title(typ)))
		}
	}
	fmt.Println("func main() {")
	for _, fun := range tocall {
		fmt.Printf("\t%s()\n", fun)
		fmt.Printf("\t%sExtraVar()\n", fun)
	}
	fmt.Println("}")
}
开发者ID:2thetop,项目名称:go,代码行数:30,代码来源:issue5162.go

示例15: Gen

func Gen(jsonStream string, typeName string) (string, error) {
	typeBody := header + "type "
	typeBody = typeBody + strings.Title(typeName) + " struct {"
	typeBody = typeBody + footer + fmt.Sprintf("\n")
	typeBody = typeBody + fmt.Sprintf("\n")
	dec := json.NewDecoder(strings.NewReader(jsonStream))
	status := InitStatus
	tmp := ""
	type2 := ""
	for {
		t, err := dec.Token()
		if err == io.EOF {
			break
		}
		if err != nil {
			log.Fatal(err)
			return "", err
		}
		tmp = fmt.Sprintf("%v", t)
		if fmt.Sprintf("%T", t) == "string" && status == InitStatus {
			typeBody = typeBody + fmt.Sprintf("\t") +
				strings.Title(tmp) + " "
			status = WaitStatus
			type2 = tmp
		} else if status == WaitStatus {
			typeBody = typeBody + fmt.Sprintf("%T", t) + " `json:\"" + type2 + "\"`" + fmt.Sprintf("\n")
			status = InitStatus
		}
	}
	typeBody = typeBody + "}"
	return typeBody, nil
}
开发者ID:mingderwang,项目名称:pepper,代码行数:32,代码来源:jsonToGo.go


注:本文中的strings.Title函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。