Fix lint and format code in task dir

This commit is contained in:
loyalsoldier 2021-06-06 21:05:27 +08:00
parent ca328208cc
commit 6738009081
No known key found for this signature in database
GPG Key ID: 23829BBC1ACF2C90
3 changed files with 5 additions and 10 deletions

View File

@ -50,6 +50,7 @@
- Feature issue #4402 finish router get example. [4416](https://github.com/beego/beego/pull/4416)
- Proposal: Add Bind() method for `web.Controller` [4491](https://github.com/beego/beego/issues/4579)
- Optimize AddAutoPrefix: only register one router in case-insensitive mode. [4582](https://github.com/beego/beego/pull/4582)
- Fix lint and format code in task dir [4655](https://github.com/beego/beego/pull/4655)
- Init exceptMethod by using reflection. [4583](https://github.com/beego/beego/pull/4583)
- Deprecated BeeMap and replace all usage with `sync.map` [4616](https://github.com/beego/beego/pull/4616)
- TaskManager support graceful shutdown [4635](https://github.com/beego/beego/pull/4635)

View File

@ -24,8 +24,7 @@ import (
"github.com/beego/beego/v2/core/admin"
)
type listTaskCommand struct {
}
type listTaskCommand struct{}
func (l *listTaskCommand) Execute(params ...interface{}) *admin.Result {
resultList := make([][]string, 0, len(globalTaskManager.adminTaskList))
@ -45,8 +44,7 @@ func (l *listTaskCommand) Execute(params ...interface{}) *admin.Result {
}
}
type runTaskCommand struct {
}
type runTaskCommand struct{}
func (r *runTaskCommand) Execute(params ...interface{}) *admin.Result {
if len(params) == 0 {
@ -83,7 +81,6 @@ func (r *runTaskCommand) Execute(params ...interface{}) *admin.Result {
Error: errors.New(fmt.Sprintf("task with name %s not found", tn)),
}
}
}
func registerCommands() {

View File

@ -137,7 +137,6 @@ type Task struct {
// NewTask add new task with name, time and func
func NewTask(tname string, spec string, f TaskFunc, opts ...Option) *Task {
task := &Task{
Taskname: tname,
DoFunc: f,
@ -351,7 +350,6 @@ func (t *Task) parseSpec(spec string) *Schedule {
// Next set schedule to next time
func (s *Schedule) Next(t time.Time) time.Time {
// Start at the earliest possible time (the upcoming second).
t = t.Add(1*time.Second - time.Duration(t.Nanosecond())*time.Nanosecond)
@ -548,7 +546,7 @@ func (m *taskManager) markManagerStop() {
// runNextTasks it runs next task which next run time is equal to effective
func (m *taskManager) runNextTasks(sortList *MapSorter, effective time.Time) {
// Run every entry whose next time was this effective time.
var i = 0
i := 0
for _, e := range sortList.Vals {
i++
if e.GetNext(context.Background()) != effective {
@ -617,7 +615,6 @@ func (m *taskManager) AddTask(taskname string, t Tasker) {
m.changed <- true
}()
}
}
// DeleteTask delete task with name
@ -690,6 +687,7 @@ func (ms *MapSorter) Less(i, j int) bool {
}
return ms.Vals[i].GetNext(context.Background()).Before(ms.Vals[j].GetNext(context.Background()))
}
func (ms *MapSorter) Swap(i, j int) {
ms.Vals[i], ms.Vals[j] = ms.Vals[j], ms.Vals[i]
ms.Keys[i], ms.Keys[j] = ms.Keys[j], ms.Keys[i]
@ -708,7 +706,6 @@ func getField(field string, r bounds) uint64 {
// getRange returns the bits indicated by the given expression:
// number | number "-" number [ "/" number ]
func getRange(expr string, r bounds) uint64 {
var (
start, end, step uint
rangeAndStep = strings.Split(expr, "/")