dpmpa26468 2018-02-07 09:33
浏览 30
已采纳

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

I'm learning Go but I can't find this answer anywhere. Is there any official standard for file extensions in web development? I've seen multiple conventions like .tmpl and .gtpl, which is what? Thanks.

  • 写回答

1条回答 默认 最新

  • dongsong4418 2018-02-07 09:40
    关注

    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, e.g. .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. 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.

    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.

    For Go code files, I always use the .go extension, which works well with the Go toolset. It's what you generally see in official Go documentation, such as this introductory document on How to Write Go Code. For executables, I don't append any file extension. The default result when you go build <name>.gois an executable called <name>, and so that makes it a common practice.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 单片机学习顺序问题!!
  • ¥15 ikuai客户端多拨vpn,重启总是有个别重拨不上
  • ¥20 关于#anlogic#sdram#的问题,如何解决?(关键词-performance)
  • ¥15 相敏解调 matlab
  • ¥15 求lingo代码和思路
  • ¥15 公交车和无人机协同运输
  • ¥15 stm32代码移植没反应
  • ¥15 matlab基于pde算法图像修复,为什么只能对示例图像有效
  • ¥100 连续两帧图像高速减法
  • ¥15 如何绘制动力学系统的相图