
Security News
The Changelog Podcast: Practical Steps to Stay Safe on npm
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.
github.com/CorrectRoadH/likit-go
Advanced tools
likit-go is a Client library for the Likit in Golang.
go get github.com/likit/likit-go
A Comment Like Example
import (
"github.com/CorrectRoadH/likit-go"
)
type CommentServer struct {
Store *store.CommentStore
likitServer *likit.LikitServer
}
func NewCommentServer(store *store.CommentStore) *CommentServer {
return &CommentServer{
Store: store,
// the likit server address. You should replace it with your own server address
// likit.NewlikitServer("localhost:4778",false),
likitServer: likit.NewlikitServer("likit.zeabur.app:443",true),
// NewlikitServer(host string, tls bool)
// if you deploy likit server in zeabur. tls shoud be true
}
}
const businessId = "COMMENT_LIKE"
// get comment
func (s *CommentServer) ListComment(c echo.Context) error {
userId := /// get user id from jwt or cookie
// define find condition
find := ////
comments, err := s.Store.ListComment(ctx, find)
return c.JSON(http.StatusOK, lo.Map(comments, func(comment types.Comment, index int) Comment {
isLike, err := s.likitServer.IsVote(ctx, businessId, comment.Id, comment.UserId)
if err != nil {
// handle error
}
likeNum, err := s.likitServer.Count(ctx, businessId, comment.Id)
if err != nil {
// handle err
}
return convertComment(comment, isLike, likeNum)
}))
}
func (s *CommentServer) Like(c echo.Context) (*apiv1pb.LikeResponse, error) {
userId := /// get user id from jwt or cookie
commentId := /// get comment id from request
count, err := s.likitServer.Vote(ctx, businessId, commentId, UserId)
if err != nil {
// handle error
}
return c.JSON(http.StatusOK, Count: count)
}
func (s *CommentServer) Unlike(c echo.Context) (*apiv1pb.LikeResponse, error) {
userId := /// get user id from jwt or cookie
commentId := /// get comment id from request
count, err := s.likitServer.UnVote(ctx, businessId, commentId, UserId)
if err != nil {
// handle error
}
return c.JSON(http.StatusOK, Count: count)
}
FAQs
Unknown package
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.

Security News
Experts push back on new claims about AI-driven ransomware, warning that hype and sponsored research are distorting how the threat is understood.

Security News
Ruby's creator Matz assumes control of RubyGems and Bundler repositories while former maintainers agree to step back and transfer all rights to end the dispute.