本文整理汇总了Golang中github.com/k0kubun/pp.Println函数的典型用法代码示例。如果您正苦于以下问题:Golang Println函数的具体用法?Golang Println怎么用?Golang Println使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Println函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: sendInquiry
func sendInquiry(c web.C, w http.ResponseWriter, r *http.Request) {
formData := make(map[string][]string)
if err := r.ParseForm(); err != nil {
panic("parse error")
} else {
formData = r.PostForm
}
pp.Println(formData)
session, _ := store.Get(r, "inqury")
session.Values["message"] = "send inquery"
buf := new(bytes.Buffer)
gob.Register(map[string][]string{})
enc := gob.NewEncoder(buf)
if err := enc.Encode(&formData); err != nil {
pp.Println(err)
}
session.Values["formData"] = formData
if err := session.Save(r, w); err != nil {
pp.Println(err)
}
http.Redirect(w, r, "/", http.StatusFound)
}
开发者ID:sheercat,项目名称:anyweb,代码行数:26,代码来源:main.go
示例2: SaveCustomer
// 顧客情報を保存します。
func SaveCustomer(customer *Customer) (*Customer, error) {
db, err := common.GetDB()
if err != nil {
panic(err.Error())
}
defer db.Close()
pp.Println(customer)
var existCustomer Customer
db.Where("ID = ?", customer.ID).First(&existCustomer)
pp.Println(existCustomer)
if existCustomer.ID != "" {
// 更新
customer.UpdatedAt = time.Now()
db.Model(&customer).Where("ID = ?", customer.ID).Update(customer)
} else {
// 新規登録
customer.ID = uuid.NewV4().String()
customer.CreatedAt = time.Now()
db.Create(&customer)
}
return customer, err
}
开发者ID:yoito,项目名称:nasuzugaru-server,代码行数:28,代码来源:customer.go
示例3: inquiry
func inquiry(c web.C, w http.ResponseWriter, r *http.Request) {
if tpl, err := pongo2.DefaultSet.FromFile("inquiry.tpl"); err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
} else {
session, _ := store.Get(r, "inqury")
message := ""
msg := session.Values["message"]
_, ok := msg.(string)
if ok {
message = msg.(string)
session.Values["message"] = nil
session.Save(r, w)
}
bytes, err := tpl.ExecuteBytes(pongo2.Context{"title": "inquiry", "message": message})
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
}
formData := session.Values["formData"]
if formData != nil {
pp.Println(formData)
bytes = fillinform.Fill(bytes, formData.(map[string][]string), nil)
session.Values["formData"] = nil
if err := session.Save(r, w); err != nil {
pp.Println(err)
}
}
w.Write(bytes)
}
}
开发者ID:sheercat,项目名称:anyweb,代码行数:30,代码来源:main.go
示例4: Say
func (c ChatServerClientSlack) Say(ch string, msg string) {
pp.Println(ch, msg)
title := "alert"
// 引用でおくるとき
_, err := json.Marshal(&payload{Attachments: []*attachment{
&attachment{
Fallback: title,
Pretext: title,
Fields: []*field{
&field{
Title: "",
Value: msg,
Short: false,
},
},
},
},
})
// フラットなテキスト + channel override
p, err := json.Marshal(&textPayload{Text: msg, Channel: ch})
res, err := http.PostForm(c.WebHookURL, url.Values{"payload": []string{string(p)}})
if err != nil {
log.Println("error on slack")
}
if res.StatusCode != 200 {
pp.Println(res.Status)
}
}
开发者ID:sheercat,项目名称:glance,代码行数:28,代码来源:chat_client_slack.go
示例5: PayPalPaymentExecute
func PayPalPaymentExecute(ctx context.Context, w http.ResponseWriter, r *http.Request) {
pp.Println(r.Header)
pp.Println(r.Cookies())
buf := bytes.NewBufferString(fmt.Sprintf("{ \"payer_id\" : \"%s\"}", r.FormValue("PayerID")))
req, err := http.NewRequest("POST", fmt.Sprintf("https://api.sandbox.paypal.com/v1/payments/payment/%s/execute/", r.FormValue("paymentId")), buf)
if err != nil {
log.Fatalln(err)
renderer.JSON(w, 400, err.Error())
return
}
req.Header.Add("Content-Type", "application/json")
req.Header.Add("Authorization", fmt.Println("Bearer %s", authToken))
res, err := http.DefaultClient.Do(req)
if err != nil {
log.Fatalln(err)
renderer.JSON(w, 400, err.Error())
return
}
defer res.Body.Close()
data, err := ioutil.ReadAll(res.Body)
if err != nil {
log.Fatalln(err)
renderer.JSON(w, 400, err.Error())
return
}
fmt.Println(string(data))
http.Redirect(w, r, "/payment/done", 302)
}
开发者ID:kyokomi-sandbox,项目名称:sandbox,代码行数:33,代码来源:main.go
示例6: main
func main() {
cfg := NewConfig()
if err := cfg.Load("config.json"); err != nil {
log.Printf("[ERROR] %+v", err)
return
}
defer func() {
if err := cfg.Save(); err != nil {
log.Printf("[ERROR] %+v", err)
return
}
}()
if len(cfg.Ips) > 100 {
for k, v := range cfg.Ips {
cfg.DeleteIp(k)
log.Printf("Delete IP %s: %s", k, v)
break
}
}
fake.SetLang("ru")
ipParams := cfg.SetIp(fake.IPv4(), true)
ipParams.Description = fake.FullName()
ipParams.SetExpire(time.Now().Add(time.Minute))
pp.Println(cfg.AllowIp("181.113.250.128"))
pp.Println(cfg.AllowIp("89.155.206.159"))
}
开发者ID:plumbum,项目名称:go-samples,代码行数:30,代码来源:main.go
示例7: apiCall
func apiCall(method string, params url.Values, callback func([]byte)) error {
params.Set("token", SLACK_TOKEN)
u := SLACK_API_URL + method
res, err := http.PostForm(u, params)
pp.Println(res.Request)
pp.Println(res.Header)
if err != nil {
if data, err := createErrorResponse(res.StatusCode); err != nil {
return err
} else {
callback(data)
}
}
pp.Println(res.StatusCode)
if res.StatusCode == http.StatusOK {
if resData, err := ioutil.ReadAll(res.Body); err != nil {
return err
} else {
callback(resData)
}
} else {
if data, err := createErrorResponse(res.StatusCode); err != nil {
return err
} else {
callback(data)
}
}
return nil
}
开发者ID:kyokomi-sandbox,项目名称:sandbox,代码行数:32,代码来源:websocket.go
示例8: Loop
func (conn *Connection) Loop() {
for {
ws, err := conn.newWSConnection()
if err != nil {
log.Fatal(err)
}
defer ws.Close()
ws.SetDeadline(time.Now().Add(10 * time.Minute))
func() {
for {
data := json.RawMessage{}
if err := websocket.JSON.Receive(ws, &data); err != nil {
log.Printf("failed websocket json receive: %v", err)
return
}
event := &Type{}
if err := json.Unmarshal(data, event); err != nil {
log.Printf("failed json unmarshal: %v", err)
continue
}
v, ok := eventMapping[event.Type]
if !ok {
continue
}
typeOf := reflect.TypeOf(v)
ep := reflect.New(typeOf).Interface()
if err := json.Unmarshal(data, ep); err != nil {
log.Printf("failed json unmarshal for type: %v", err)
continue
}
switch e := ep.(type) {
case *HelloEvent:
// ...
case *MessageEvent:
conn.CallCb(*e)
case *ChannelCreatedEvent:
conn.channelMap[e.Channel.Id] = e.Channel.Name
pp.Println(conn.channelMap)
case *ChannelDeletedEvent:
delete(conn.channelMap, e.Channel)
pp.Println(conn.channelMap)
case *ChannelRenameEvent:
conn.channelMap[e.Channel.Id] = e.Channel.Name
pp.Println(conn.channelMap)
case *UserChangeEvent:
conn.userMap[e.User.Id] = e.User.Name
pp.Println(conn.userMap)
default:
}
}
}()
}
}
开发者ID:mix3,项目名称:guiniol,代码行数:59,代码来源:connection.go
示例9: PaymentDone
func PaymentDone(ctx context.Context, w http.ResponseWriter, r *http.Request) {
r.ParseForm()
pp.Println(r.Form)
pp.Println(r.Header)
pp.Println(r.Cookies())
w.Write([]byte("OK"))
}
开发者ID:kyokomi-sandbox,项目名称:sandbox,代码行数:8,代码来源:main.go
示例10: TestQueryMemoryCache
func TestQueryMemoryCache(t *testing.T) {
s := New()
defer s.Close()
q := s.QueryMemoryCache(testQuery, testArgs...)
pp.Println(q)
q = s.QueryMemoryCache(testQuery, testArgs...)
pp.Println(q)
}
开发者ID:kyokomi-sandbox,项目名称:sandbox,代码行数:9,代码来源:sqlcache_test.go
示例11: TestQueryKVSCache
func TestQueryKVSCache(t *testing.T) {
s := New()
defer s.Close()
cacheKey := fmt.Sprintf("%s:%v", testQuery, testArgs)
s.KVS.Del(cacheKey)
q := s.QueryKVSCache(testQuery, testArgs...)
pp.Println(q)
q = s.QueryKVSCache(testQuery, testArgs...)
pp.Println(q)
}
开发者ID:kyokomi-sandbox,项目名称:sandbox,代码行数:12,代码来源:sqlcache_test.go
示例12: main
func main() {
fmt.Println("Hello world!")
err := getError()
err = errors.Wrap(err, "open failed")
err = subErr(err)
err = errors.Wrap(err, "read config failed")
pp.Println("Cause: ", errors.Cause(err))
err = errors.Wrap(err, "New message")
pp.Println("Error: ", err)
fmt.Printf("[%+v]\n", err)
fmt.Printf("{%+v}\n", errors.Cause(err))
fmt.Printf("[%v]\n", err)
}
开发者ID:plumbum,项目名称:go-samples,代码行数:14,代码来源:main.go
示例13: DebugDump
func DebugDump(v ...interface{}) {
if IsDebugging() {
for _, r := range v {
pp.Println(r)
}
}
}
开发者ID:gophergala2016,项目名称:source,代码行数:7,代码来源:debug.go
示例14: itemHandler
func itemHandler(feed *rss.Feed, ch *rss.Channel, newitems []*rss.Item) {
fmt.Println("itemHandler")
fmt.Println(len(newitems), "new item(s) in", ch.Title, "of", feed.Url)
for _, item := range newitems {
pp.Println(item)
}
}
开发者ID:kyokomi-sandbox,项目名称:sandbox,代码行数:7,代码来源:rss.go
示例15: main
func main() {
// Init loggers
scenariolib.InitLogger(ioutil.Discard, os.Stdout, os.Stdout, os.Stderr)
// Seed Random based on current time
source := rand.NewSource(int64(time.Now().Unix()))
random := rand.New(source)
searchToken := os.Getenv("SEARCHTOKEN")
analyticsToken := os.Getenv("UATOKEN")
if searchToken == "" || analyticsToken == "" {
scenariolib.Error.Println("SEARCHTOKEN, UATOKEN need to be defined as env variables")
}
scenarioURL := os.Getenv("SCENARIOSURL")
if scenarioURL == "" {
scenariolib.Error.Println("SCENARIOSURL env variable needs to define a file path")
}
local := os.Getenv("LOCAL") == "true"
if local {
scenariolib.Info.Println("STARTING IN LOCAL MODE, MAKE SURE THE SCENARIOSURL IS A LOCAL PATH")
}
bot := scenariolib.NewUabot(local, scenarioURL, searchToken, analyticsToken, random)
quit := make(chan bool)
err := bot.Run(quit)
if err != nil {
scenariolib.Error.Println(err)
}
pp.Println("LOG >>> DONE")
}
开发者ID:coveo,项目名称:uabot,代码行数:33,代码来源:main.go
示例16: chanHandler
func chanHandler(feed *rss.Feed, newchannels []*rss.Channel) {
fmt.Println("chanHandler")
fmt.Println(len(newchannels), "new channel(s) in", feed.Url)
for _, c := range newchannels {
pp.Println(c)
}
}
开发者ID:kyokomi-sandbox,项目名称:sandbox,代码行数:7,代码来源:rss.go
示例17: main
func main() {
var err error
ta := &data.Users{}
ta.Users = []data.Item{
{1, "John", "123"},
{2, "Bob", "123"},
{3, "Mary", "123"},
{4, "Dave", "123"},
{5, "Ken", "123"},
}
log.Println("Marshal default")
str, err := json.Marshal(ta)
chk(err)
fmt.Println(string(str))
log.Println("Marshal ffjson")
str2, err := ta.MarshalJSON()
chk(err)
fmt.Println(string(str2))
log.Println("Unmarshal array")
json_str := `[[1, 2, 3], [4, 5, 6], [7, 8, 9]]`
a := make([]Item, 0)
err = json.Unmarshal([]byte(json_str), &a)
chk(err)
pp.Println(a)
}
开发者ID:plumbum,项目名称:go-samples,代码行数:31,代码来源:json.go
示例18: DumpAST
func DumpAST(body string) {
scanner := new(parsing.Scanner)
scanner.Init([]rune(body), 0)
defs := parsing.Parse(scanner)
pp.Println(defs)
}
开发者ID:psg-titech,项目名称:sandal2,代码行数:7,代码来源:driver.go
示例19: DumpIR1
func DumpIR1(defs []Def) {
err, intMods := astToIr1(defs)
if err != nil {
log.Fatal("Conversion error: ", err)
}
pp.Println(intMods)
}
开发者ID:psg-titech,项目名称:sandal2,代码行数:7,代码来源:driver.go
示例20: main
func main() {
c := table.New(azure.StorageCredentials{
AccountName: os.Getenv("AZURE_STORAGE_ACCOUNT_NAME"),
AccessKey: os.Getenv("AZURE_STORAGE_ACCESS_KEY"),
})
c.Debug = true
err := c.Create("messages")
if err != nil {
fmt.Println(err)
}
err = c.Insert("messages", Message{
Body: "My message body!",
RowKey: "1",
PartitionKey: "network-1",
})
if err != nil {
fmt.Println(err)
}
m := &Message{}
err = c.GetEntity(table.RowQuery{
Table: "messages",
PartitionKey: "network-1",
RowKey: "1",
Fields: []string{"Body", "RowKey", "PartitionKey"},
}, m)
if err != nil {
fmt.Println(err)
}
pp.Println(m)
}
开发者ID:bmorton,项目名称:go-azure,代码行数:35,代码来源:example.go
注:本文中的github.com/k0kubun/pp.Println函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论