mirror of
https://github.com/syumai/workers.git
synced 2025-03-10 17:29:11 +00:00
remove jsutil.NewUUID()
This commit is contained in:
parent
acf15ae798
commit
0f092cebed
@ -8,11 +8,12 @@ import (
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
|
||||
"github.com/mailru/easyjson"
|
||||
"github.com/syumai/workers/cloudflare/d1"
|
||||
_ "github.com/syumai/workers/cloudflare/d1" // register driver
|
||||
"github.com/syumai/workers/examples/d1-blog-server/app/model"
|
||||
"github.com/syumai/workers/internal/jsutil"
|
||||
)
|
||||
|
||||
type articleHandler struct{}
|
||||
@ -62,7 +63,7 @@ func (h *articleHandler) createArticle(w http.ResponseWriter, req *http.Request,
|
||||
|
||||
now := time.Now().Unix()
|
||||
article := model.Article{
|
||||
ID: jsutil.NewUUID(),
|
||||
ID: uuid.New().String(),
|
||||
Title: createArticleReq.Title,
|
||||
Body: createArticleReq.Body,
|
||||
CreatedAt: uint64(now),
|
||||
|
@ -9,4 +9,7 @@ require (
|
||||
|
||||
replace github.com/syumai/workers => ../../
|
||||
|
||||
require github.com/josharian/intern v1.0.0 // indirect
|
||||
require (
|
||||
github.com/google/uuid v1.3.0 // indirect
|
||||
github.com/josharian/intern v1.0.0 // indirect
|
||||
)
|
||||
|
@ -1,3 +1,5 @@
|
||||
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
|
||||
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY=
|
||||
github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
|
||||
github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0=
|
||||
|
@ -18,7 +18,6 @@ var (
|
||||
ErrorClass = Global.Get("Error")
|
||||
ReadableStreamClass = Global.Get("ReadableStream")
|
||||
DateClass = Global.Get("Date")
|
||||
Crypto = Global.Get("crypto")
|
||||
)
|
||||
|
||||
func NewObject() js.Value {
|
||||
@ -103,7 +102,3 @@ func DateToTime(v js.Value) (time.Time, error) {
|
||||
func TimeToDate(t time.Time) js.Value {
|
||||
return DateClass.New(t.UnixMilli())
|
||||
}
|
||||
|
||||
func NewUUID() string {
|
||||
return Crypto.Call("randomUUID").String()
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user