Documentation ¶
Index ¶
Constants ¶
const ExecTag = "exec"
ExecTag stands for the path of executable file in command. If we want this util works , we must add Exec in the struct and use NewExec() to initialize it, because the default way to initialize Exec means None in code.
const ParaTag = "para"
ParaTag stands for parameters in command. We can use it in struct fields as a tag. Just like Port below
type Iptables Struct { Exec Port string `para:"-p"` }
If the field is not string type or []string type , it will bring an error. If the tag value like "-p" is empty string , the para will just add the field value into the command just as some single value parameter in command. If the value of field is empty string or empty string slice or empty slice, the field and tag will all be skipped.
const SubCommandTag = "sub_command"
SubCommandTag stands for the sub command in common command. We can use it in struct fields as a tag. Just like MatchExtension below
type Iptables Struct { Exec MatchExtension Match `sub_command:""` } type Match Struct { Exec Port string `para:"-p"` }
Field with SubcommandTag needs to be a struct with Exec.
Variables ¶
This section is empty.