本文整理汇总了Golang中github.com/ubuntu-core/snappy/logger.Panicf函数的典型用法代码示例。如果您正苦于以下问题:Golang Panicf函数的具体用法?Golang Panicf怎么用?Golang Panicf使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Panicf函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Parser
// Parser creates and populates a fresh parser.
// Since commands have local state a fresh parser is required to isolate tests
// from each other.
func Parser() *flags.Parser {
parser := flags.NewParser(&optionsData, flags.HelpFlag|flags.PassDoubleDash)
// Add all regular commands
for _, c := range commands {
cmd, err := parser.AddCommand(c.name, c.shortHelp, strings.TrimSpace(c.longHelp), c.builder())
if err != nil {
logger.Panicf("cannot add command %q: %v", c.name, err)
}
cmd.Hidden = c.hidden
}
// Add the experimental command
experimentalCommand, err := parser.AddCommand("experimental", shortExperimentalHelp, longExperimentalHelp, &cmdExperimental{})
experimentalCommand.Hidden = true
if err != nil {
logger.Panicf("cannot add command %q: %v", "experimental", err)
}
// Add all the sub-commands of the experimental command
for _, c := range experimentalCommands {
cmd, err := experimentalCommand.AddCommand(c.name, c.shortHelp, strings.TrimSpace(c.longHelp), c.builder())
if err != nil {
logger.Panicf("cannot add experimental command %q: %v", c.name, err)
}
cmd.Hidden = c.hidden
}
return parser
}
示例2: init
func init() {
_, err := parser.AddCommand("enable-classic",
i18n.G("Enable classic dimension."),
i18n.G("Enable the ubuntu classic dimension."),
&cmdEnableClassic{})
if err != nil {
logger.Panicf("Unable to enable-classic: %v", err)
}
_, err = parser.AddCommand("destroy-classic",
i18n.G("Destroy the classic dimension."),
i18n.G("Destroy the ubuntu classic dimension."),
&cmdDestroyClassic{})
if err != nil {
logger.Panicf("Unable to destroy-classic: %v", err)
}
}
示例3: init
func init() {
_, err := parser.AddCommand("activate",
i18n.G(`Activate a package`),
i18n.G(`Activate a package that has previously been deactivated. If the package is already activated, do nothing.`),
&cmdActivate{activate: true})
if err != nil {
logger.Panicf("Unable to activate: %v", err)
}
_, err = parser.AddCommand("deactivate",
i18n.G(`Deactivate a package`),
i18n.G(`Deactivate a package. If the package is already deactivated, do nothing.`),
&cmdActivate{activate: false})
if err != nil {
logger.Panicf("Unable to deactivate: %v", err)
}
}
示例4: set
func (data customData) set(key string, value interface{}) {
serialized, err := json.Marshal(value)
if err != nil {
logger.Panicf("internal error: could not marshal value for state entry %q: %v", key, err)
}
entryJSON := json.RawMessage(serialized)
data[key] = &entryJSON
}
示例5: checkpointData
func (s *State) checkpointData() []byte {
data, err := json.Marshal(s)
if err != nil {
// this shouldn't happen, because the actual delicate serializing happens at various Set()s
logger.Panicf("internal error: could not marshal state for checkpointing: %v", err)
}
return data
}
示例6: init
func init() {
_, err := parser.AddCommand("grub-migrate",
"internal",
"internal",
&cmdGrubMigrate{})
if err != nil {
logger.Panicf("Unable to grub-migrate: %v", err)
}
}
示例7: init
func init() {
_, err := parser.AddCommand("versions",
shortVersionsHelp,
longVersionsHelp,
&cmdVersions{})
if err != nil {
logger.Panicf("Unable to versions: %v", err)
}
}
示例8: init
func init() {
_, err := parser.AddCommand("console",
"Run snappy console interface",
"Run snappy console interface",
&cmdConsole{})
if err != nil {
logger.Panicf("Unable to console: %v", err)
}
}
示例9: init
func init() {
_, err := parser.AddCommand("firstboot",
"internal",
"internal",
&cmdInternalFirstBootOemConfig{})
if err != nil {
logger.Panicf("Unable to first_boot: %v", err)
}
}
示例10: init
func init() {
_, err := parser.AddCommand("booted",
"internal",
"internal",
&cmdBooted{})
if err != nil {
logger.Panicf("Unable to booted: %v", err)
}
}
示例11: init
func init() {
_, err := parser.AddCommand("internal-run-hooks",
"internal",
"internal",
&cmdInternalRunHooks{})
if err != nil {
logger.Panicf("Unable to internal_run_hooks: %v", err)
}
}
示例12: init
func init() {
_, err := parser.AddCommand("set",
i18n.G("Set properties of system or package"),
setHelp,
&cmdSet{})
if err != nil {
logger.Panicf("Unable to set: %v", err)
}
}
示例13: init
func init() {
_, err := parser.AddCommand("internal-unpack",
"internal",
"internal",
&cmdInternalUnpack{})
if err != nil {
logger.Panicf("Unable to internal_unpack: %v", err)
}
}
示例14: init
func init() {
arg, err := parser.AddCommand("hw-info",
shortHWInfoHelp,
longHWInfoHelp,
&cmdHWInfo{})
if err != nil {
logger.Panicf("Unable to hwinfo: %v", err)
}
addOptionDescription(arg, "package name", i18n.G("List assigned hardware for a specific installed package"))
}
示例15: init
func init() {
arg, err := parser.AddCommand("shell",
i18n.G("Run snappy shell interface"),
i18n.G("Run snappy shell interface"),
&cmdShell{})
if err != nil {
logger.Panicf("Unable to add shell command: %q", err)
}
addOptionDescription(arg, "shell-type", i18n.G("The type of shell you want"))
}