-
Hello visitors, welcome to the Hacker World Forum!
Red Team 1949 (formerly CHT Attack and Defense Team) In this rapidly changing Internet era, we maintain our original intention and create the best community to jointly exchange network technologies. You can obtain hacker attack and defense skills and knowledge in the forum, or you can join our Telegram communication group to discuss and communicate in real time. All kinds of advertisements are prohibited in the forum. Please register as a registered user to check our usage and privacy policy. Thank you for your cooperation.
TheHackerWorld Official
- 0
Question
HACK1949
在goland中读取tpl文件的图文操作
近来开始研究golang,使用国人做的beego框架做页面开发,以前用pycharm开发的,所以习惯了 就采用了goland,不过有个问题,就是在做页面模版时候采用tpl后缀,需要进行设置一下。(mac系统,如果windows系统 在setting中)如下:
按顺序 editor->file types,在recongized fiel types中找到HTML,然后在下面可以看到 后缀形式,点击添加*.tpl 然后保存退出 就可以搞定了。
接下来 是补全问题:
要用到一些特殊的格式,比如 {{ … }},{{ if }}{{end}}等等,如果不设置,只能一个符号一个符号的输入。现在教大家如何设置自动补全这些东西。
按顺序是在editor->live templates 中 选择添加
添加标签
Abbreviation 处添加标签,比如 if
Description 是描述这个标签用途的,随便写。
Template text 就是补全的文本了。
$END$表示补全后光标移动到此处。
选择标签应用到哪些文件类型
使用时在tpl或者其他html文件中 输入if进行tab 就可以补全。
补充:goland读取文件写入文件
我就废话不多说了,大家还是直接看代码吧~
package main
import (
"fmt"
"io/ioutil"
"strings"
)
/**
* 读取文件
* string name 文件名称
*/
func ReadFile(name string) {
if contents,err := ioutil.ReadFile(name);err == nil {
result := strings.Replace(string(contents),"\n","",1)
fmt.Println("ReadFile:",result)
}
}
/**
* 写入文件
* string name 文件名称
* byte content 文件内容
*/
func WriteFile(name string, content []byte){
if ioutil.WriteFile(name, content, 0644) == nil{
fmt.Println("WriteFile")
}else{
fmt.Println("NOT WriteFile")
}
}
func main() {
name := "content.txt"
content := "content"
WriteFile(name, []byte(content))
ReadFile(name)
}
以上为个人经验,希望能给大家一个参考
Link to post
Link to comment
Share on other sites
0 answers to this question
Recommended Posts