-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
文档 #1
Comments
非常抱歉,目前只完成了测试,后续还未来得及开发,具体使用可以参考/core/resolv目录下load_test.go和save_test.go
load_test.go:
func TestLoad(t *testing.T) {
conf, err := Load("../../test/nginx.conf") // "../../test/nginx.conf"为nginx的主配置文件路径
if err != nil {
t.Log(err)
}
t.Log(conf.String()) // conf.String()将打印nginx的配置
}
save_test.go:
func TestSave(t *testing.T) {
conf, err := Load("../../test/nginx.conf") // "../../test/nginx.conf"为nginx的主配置文件路径
if err != nil {
t.Log(err)
}
serr := Save(conf) // 将根据"../../test/nginx.conf"路径进行配置文件的报错,包括include的子配置文件
if serr != nil {
t.Log(serr)
}
}
…------------------ 原始邮件 ------------------
发件人: "Tasmanian Devil"<notifications@github.com>;
发送时间: 2020年3月10日(星期二) 下午2:20
收件人: "ClessLi/go-nginx-conf-parser"<go-nginx-conf-parser@noreply.github.com>;
抄送: "Subscribed"<subscribed@noreply.github.com>;
主题: [ClessLi/go-nginx-conf-parser] 文档 (#1)
请问 , 这个怎么使用 , 有相关文档吗
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
非常抱歉,目前只完成了测试,后续还未来得及开发,具体使用可以参考/core/resolv目录下load_test.go和save_test.go
load_test.go:
func TestLoad(t *testing.T) {
conf, err := Load("../../test/nginx.conf") // "../../test/nginx.conf"为nginx的主配置文件路径
if err != nil {
t.Log(err)
}
t.Log(conf.String()) // conf.String()将打印nginx的配置
}
save_test.go:
func TestSave(t *testing.T) {
conf, err := Load("../../test/nginx.conf") // "../../test/nginx.conf"为nginx的主配置文件路径
if err != nil {
t.Log(err)
}
serr := Save(conf) // 将根据"../../test/nginx.conf"路径进行配置文件的保存,包括include的子配置文件
if serr != nil {
t.Log(serr)
}
}
ps. 刚才那封邮件中把“保存”写成“报错”了,此封邮件为更正用
…------------------ 原始邮件 ------------------
发件人: "Tasmanian Devil"<notifications@github.com>;
发送时间: 2020年3月10日(星期二) 下午2:20
收件人: "ClessLi/go-nginx-conf-parser"<go-nginx-conf-parser@noreply.github.com>;
抄送: "Subscribed"<subscribed@noreply.github.com>;
主题: [ClessLi/go-nginx-conf-parser] 文档 (#1)
请问 , 这个怎么使用 , 有相关文档吗
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
好的 , 多谢 , 这里是直接加载, 输出一个值 , 能不能实现, 配置文件结构体化 |
输出 |
Load函数将返回Config对象
func Load(path string) (*Config, error) {
absPath, err := filepath.Abs(path)
if err != nil {
return nil, err
}
return load(absPath)
}
Config对象包含了基础上下文对象(BasicContext)
type Config struct {
BasicContext
}
BasicContext对象实现了Context接口
// Context, 上下文接口对象,定义了上下文接口需实现的增、删、改等方法
type Context interface {
Add(...Parser)
Remove(...Parser)
Modify(int, Parser) error
//Filter(string, string) *Context
//getReg() string
//Dict() map[string]interface{}
String() []string
//BumpChildDepth(int)
dump() ([]string, error)
}
// BasicContext, 上下文基础对象,定义了上下文类型的基本属性及基础方法
type BasicContext struct {
Name string
Value string
depth int
Children []Parser
}
Context接口有增删查改的方法
…------------------ 原始邮件 ------------------
发件人: "イフリート"<316600949@qq.com>;
发送时间: 2020年3月10日(星期二) 下午2:42
收件人: "ClessLi/go-nginx-conf-parser"<reply@reply.github.com>;
主题: 回复:[ClessLi/go-nginx-conf-parser] 文档 (#1)
非常抱歉,目前只完成了测试,后续还未来得及开发,具体使用可以参考/core/resolv目录下load_test.go和save_test.go
load_test.go:
func TestLoad(t *testing.T) {
conf, err := Load("../../test/nginx.conf") // "../../test/nginx.conf"为nginx的主配置文件路径
if err != nil {
t.Log(err)
}
t.Log(conf.String()) // conf.String()将打印nginx的配置
}
save_test.go:
func TestSave(t *testing.T) {
conf, err := Load("../../test/nginx.conf") // "../../test/nginx.conf"为nginx的主配置文件路径
if err != nil {
t.Log(err)
}
serr := Save(conf) // 将根据"../../test/nginx.conf"路径进行配置文件的保存,包括include的子配置文件
if serr != nil {
t.Log(serr)
}
}
ps. 刚才那封邮件中把“保存”写成“报错”了,此封邮件为更正用
------------------ 原始邮件 ------------------
发件人: "Tasmanian Devil"<notifications@github.com>;
发送时间: 2020年3月10日(星期二) 下午2:20
收件人: "ClessLi/go-nginx-conf-parser"<go-nginx-conf-parser@noreply.github.com>;
抄送: "Subscribed"<subscribed@noreply.github.com>;
主题: [ClessLi/go-nginx-conf-parser] 文档 (#1)
请问 , 这个怎么使用 , 有相关文档吗
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
可以的,刚刚我追加了一封邮件
…------------------ 原始邮件 ------------------
发件人: "Tasmanian Devil"<notifications@github.com>;
发送时间: 2020年3月10日(星期二) 下午2:48
收件人: "ClessLi/go-nginx-conf-parser"<go-nginx-conf-parser@noreply.github.com>;
抄送: "李学渊"<316600949@qq.com>;"Comment"<comment@noreply.github.com>;
主题: Re: [ClessLi/go-nginx-conf-parser] 文档 (#1)
好的 , 多谢 , 这里是直接加载, 输出一个值 , 能不能实现, 配置文件结构体化
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
你好 , 能实现大概这种的效果吗? github.com/caas-one/nginxconf 实现这种 go 结构体 |
我这边nginx配置的对象不太一样,Config结构体下是多个上下文类,以便于上下文类具有相应的方法
…------------------ 原始邮件 ------------------
发件人: "Tasmanian Devil"<notifications@github.com>;
发送时间: 2020年3月10日(星期二) 下午3:45
收件人: "ClessLi/go-nginx-conf-parser"<go-nginx-conf-parser@noreply.github.com>;
抄送: "李学渊"<316600949@qq.com>;"Comment"<comment@noreply.github.com>;
主题: Re: [ClessLi/go-nginx-conf-parser] 文档 (#1)
你好 , 能实现大概这种的效果吗? github.com/caas-one/nginxconf 实现这种 go 结构体
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
好的 , 多谢 |
已完善项目简介、nginx配置管理后端配置启动指南及现有接口文档,resolve包的相关函数方法的备注待完善。 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
请问 , 这个怎么使用 , 有相关文档吗
The text was updated successfully, but these errors were encountered: