简体   繁体   English

是Web开发中文件扩展名的标准吗?

[英]Go standard for file extensions in web development?

I'm learning Go but I can't find this answer anywhere. 我正在学习Go,但在任何地方都找不到此答案。 Is there any official standard for file extensions in web development? Web开发中是否有文件扩展名的正式标准? I've seen multiple conventions like .tmpl and .gtpl , which is what? 我看过.tmpl.gtpl等多种约定,这是什么? Thanks. 谢谢。

There's no fixed standard, but there are some fairly common practices. 没有固定的标准,但是有一些相当普遍的做法。 For templates on web projects, I use the extension appropriate for the type of file it is, eg .html , .css , etc. That's what's done in the widely-read-and-cited Writing Web Applications blog post on the official Go blog, which makes it fairly standard. 对于Web项目上的模板,我使用适合于文件类型的扩展名,例如.html.css等。这就是在官方Go博客上广为引用和引用的Writing Web Applications博客文章中所做的事情。 ,这使其相当标准。 I find it useful for easy syntax highlighting without changing my editor's settings/config, and processing by other tools. 我发现它在无需更改编辑器的设置/配置以及其他工具进行处理的情况下,可以方便地突出显示语法。 I put these templates in a /templates/ directory to keep them separate from non-template files. 我将这些模板放在/templates/目录中,以使其与非模板文件分开。

I've seen and used .tmpl before, it's in official docs for both html and text template packages, which makes that fairly standard too, and I think it makes sense if you're making a file-type-agnostic template, or you don't have any associations that are useful by more specialized file type. 我之前已经看过并使用过.tmpl ,它在html和文本模板包的官方文档中都有,这也使它相当标准,而且我认为如果要制作与文件类型无关的模板还是有意义的没有任何更专业的文件类型有用的关联。

For Go code files, I always use the .go extension, which works well with the Go toolset. 对于Go代码文件,我始终使用.go扩展名,该扩展名与Go工具集配合使用非常好。 It's what you generally see in official Go documentation, such as this introductory document on How to Write Go Code . 这是您通常在Go官方文档中看到的内容,例如有关如何编写Go代码的入门文档 For executables, I don't append any file extension. 对于可执行文件,我不附加任何文件扩展名。 The default result when you go build <name>.go is an executable called <name> , and so that makes it a common practice. go build <name>.go时的默认结果是名为<name>的可执行文件,因此这是一种常见的做法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 standard_init_linux.go:190: exec 用户进程导致“没有这样的文件或目录”Docker 与 go basic web 应用程序 - standard_init_linux.go:190: exec user process caused "no such file or directory" Docker with go basic web app 用于Web开发的Google Go模板,具有二维数组 - Google Go Templates for Web Development with two dimensional array 处理多语言Go网络应用程序的标准/惯用方法是什么? - What is the standard/ idiomatic way to handle multilingual Go web apps? 在go web服务器上使用外部CSS文件 - Using external CSS file on a go web server Go中的应用程序开发 - Application development in Go 从Web获取zip文件并在Go中解压缩 - Fetch zip file from the web and decompress it in Go 是否有针对“构造函数”的标准惯用Go? - Is there standard idiomatic Go for “constructors”? 在Golang Web应用程序开发中,可以将Go的模板与jade(pug)模板引擎一起使用吗? - In Golang web application development, is it possible to use Go's template with the jade (pug) template engine? Go 多级 docker 构建失败,standard_init_linux.go:228:导致执行用户进程:没有这样的文件或目录 - Go multistage docker build fails with standard_init_linux.go:228: exec user process caused: no such file or directory GO 编程语言中的标准 unicode - standard unicode in GO programming language
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM