Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
A
adormit
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
jrabbit
adormit
Commits
ed6d4ee9
Commit
ed6d4ee9
authored
9 months ago
by
jrabbit
Browse files
Options
Downloads
Patches
Plain Diff
delete timers
parent
a9881930
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
adormit/adormit.go
+12
-10
12 additions, 10 deletions
adormit/adormit.go
cmd/http.go
+12
-0
12 additions, 0 deletions
cmd/http.go
with
24 additions
and
10 deletions
adormit/adormit.go
+
12
−
10
View file @
ed6d4ee9
...
...
@@ -11,6 +11,7 @@ import (
func
Version
()
string
{
return
"0.0.1a4"
}
var
CurrentTimers
[]
Timer
var
CurrentAlarms
map
[
string
]
Alarm
...
...
@@ -18,6 +19,7 @@ func Init() {
CurrentAlarms
=
make
(
map
[
string
]
Alarm
)
CurrentTimers
=
make
([]
Timer
,
0
)
}
type
Alarm
struct
{
Name
string
Early
bool
...
...
@@ -27,9 +29,11 @@ type Alarm struct {
Uuid
uuid
.
UUID
Creator
string
}
func
(
a
*
Alarm
)
String
()
string
{
return
fmt
.
Sprintf
(
"%v by %v"
,
a
.
Name
,
a
.
Creator
)
}
type
Timer
struct
{
Name
string
Start
time
.
Time
...
...
@@ -63,7 +67,6 @@ func DemoTimer() {
t
.
Countdown
()
}
func
debug
(
ty
interface
{})
{
fooType
:=
reflect
.
TypeOf
(
ty
)
fmt
.
Println
(
fooType
)
...
...
@@ -72,4 +75,3 @@ func debug(ty interface{}) {
fmt
.
Println
(
method
.
Name
)
}
}
This diff is collapsed.
Click to expand it.
cmd/http.go
+
12
−
0
View file @
ed6d4ee9
...
...
@@ -2,10 +2,12 @@ package cmd
import
(
"0xacab.org/jrabbit/adormit/adormit"
"github.com/satori/go.uuid"
"github.com/spf13/cobra"
"gopkg.in/macaron.v1"
"log"
"net/http"
"slices"
"strconv"
"time"
)
...
...
@@ -47,6 +49,16 @@ func newTimer(req *http.Request) string {
}
func
delTimer
(
req
*
http
.
Request
)
string
{
i
:=
req
.
FormValue
(
"uuid"
)
myuuid
,
_
:=
uuid
.
FromString
(
i
)
idxChecker
:=
func
(
e
adormit
.
Timer
)
bool
{
if
e
.
Uuid
==
myuuid
{
return
true
}
else
{
return
false
}
}
slices
.
DeleteFunc
(
adormit
.
CurrentTimers
,
idxChecker
)
return
"OK"
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment