Skip to content

Instantly share code, notes, and snippets.

package main
import (
"github.com/gorilla/websocket"
"github.com/sirupsen/logrus"
"net/http"
)
/**
gin.engine.Any("/ws",gin.WrapF(WsProxy))
func (s *Server) startGoRoutine(f func()) bool {
var started bool
s.grMu.Lock()
if s.grRunning {
s.grWG.Add(1)
go f()
started = true
}
s.grMu.Unlock()
return started
package main
import (
"bytes"
"encoding/binary"
"encoding/json"
"io"
"log"
"os"
"path/filepath"
find . -type f -name '*.mp3' -print -delete
#posgresql

#posgresql

docker  run   --name postgres -e POSTGRES_PASSWORD=mysecretpassword -e POSTGRES_USER=test -p 5432:5432 \
-e PGDATA=/var/lib/postgresql/data/pgdata \
-e POSTGRES_DB=foo \
-v /home/code/Desktop/postgres/data:/var/lib/postgresql/data/pgdata postgres
@dtest11
dtest11 / pg.go
Last active August 25, 2021 15:19
https://www.digitalocean.com/community/tutorials/how-to-install-postgresql-on-ubuntu-20-04-quickstart
sudo -i -u postgres
createuser --interactive
createdb test
在电脑本机商:
sudo adduser sammy
sudo -i -u sammy
@dtest11
dtest11 / bolt_loop.go
Created July 14, 2021 15:25
boltdb loop cursor
package main
import (
"fmt"
"log"
"sort"
"strconv"
"github.com/boltdb/bolt"
)
/***
enjoy you time,happy coding.
***/
// Copyright 2012-2019 The NATS Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
package main
import (
"fmt"
"log"
"time"
"github.com/nats-io/nats.go"
)