examples.go 654 B

123456789101112131415161718192021222324252627282930
  1. package jobs
  2. import (
  3. "fmt"
  4. "time"
  5. )
  6. // ExamplesOne
  7. // 新添加的job 必须按照以下格式定义,并实现Exec函数
  8. type ExamplesOne struct {
  9. }
  10. func (t *ExamplesOne) Exec(arg interface{}) error {
  11. str := time.Now().Format(timeFormat) + " [INFO] JobCore ExamplesOne exec success"
  12. // TODO: 这里需要注意 Examples 传入参数是 string 所以 arg.(string);请根据对应的类型进行转化;
  13. switch arg.(type) {
  14. case string:
  15. if arg.(string) != "" {
  16. fmt.Println("string", arg.(string))
  17. fmt.Println(str, arg.(string))
  18. } else {
  19. fmt.Println("arg is nil")
  20. fmt.Println(str, "arg is nil")
  21. }
  22. break
  23. }
  24. return nil
  25. }