goo

package module
v0.0.0-...-b64ae0a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 11, 2019 License: MIT Imports: 14 Imported by: 0

README

googege network library

GoDoc

What?

this is a network library which created by googege.This library contains a lot of wrapper functions in common web processing.

Install
go get nudao.xyz/goo
Usage
package main

import (
  "fmt"
	"nudao.xyz/goo"
)

func main() {
	value := goo.Join(nil, "a", "b", "c")
  fmt.Println(value)
}
//abc

Document in md format

Documentation

Overview

goo.go this file incloud the common functions,maps slices, structs or anything else.

mysql.go has add delete search ect about the mysql using go-sql-driver/mysql.

salt.go This file is all about encrypting and decrypting passwords. this is a example for you:

pass,salt := EncryptMd5("991182@")
passReal := "991182@"
a,b := DeEncryptMd5(passReal,pass,salt)
if b != nil || !a {
	t.Error("❌")
}
fmt.Println(pass,salt)
passErr := "123456!@"
d,e := DeEncryptMd5(passErr,pass,salt)
if e != nil || !d {
	t.Error("这个错误 应该被打印出来")
}

session.go

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertToString

func ConvertToString(src string, srcCode string, tagCode string) string

转码 将文字 从 比如 gbk转化为 utf8

func DeEncryptArgon2

func DeEncryptArgon2(password, resultDB, saltDB string) (is bool, err error)

Verify that the user's password is equal to the password in the database

func DeEncryptMd5

func DeEncryptMd5(password string, resultDB, saltDB string) (is bool, err error)

Verify that the user's password is equal to the password in the database

Example
pass, salt := EncryptMd5("991182@")
passReal := "991182@"
a, b := DeEncryptMd5(passReal, pass, salt)
if b != nil || !a {
	fmt.Println("x")
	//	output:x
}
passErr := "123456!@"
d, e := DeEncryptMd5(passErr, pass, salt)
if e != nil || !d {
	fmt.Println("err")
	
Output:

err

func EncryptArgon2

func EncryptArgon2(password string) (resultDB, saltDB string)

return result and salt. Use hexadecimal to save []byte of data.

func EncryptMd5

func EncryptMd5(password string) (resultDB, saltDB string)

use md5+salt return result and salt.

func GetCookie

func GetCookie(r *http.Request, cookieName string) (*http.Cookie, error)

get cookie

func SetCookie

func SetCookie(w http.ResponseWriter, cookie *http.Cookie)

set cookie

Types

type Data

type Data struct {
	Data Values `json:"data"`
}

type IntSet

type IntSet struct {
	Words []uint64 // bit array
}

InSet is a bit array struct.

func (*IntSet) Clear

func (i *IntSet) Clear()

clear the array,and let i.Words point a new slice.

func (*IntSet) Copy

func (i *IntSet) Copy() *IntSet

copy form the old array to a new array,return a new instance's pointer.

func (*IntSet) Len

func (i *IntSet) Len() int

Len return a int type value about the bit array's length.

func (*IntSet) Remove

func (i *IntSet) Remove(x int)

remove this array's one bit.

type Session

type Session interface {
	Get(key interface{}) interface{}
	Set(key, value interface{}) error
	Delete(key interface{}) error
	SessionID() string
}

Session interface

func NewSession

func NewSession() Session

newSession new a session object.

type SessionStore

type SessionStore struct {
	// contains filtered or unexported fields
}

the main manager about the session system

func (*SessionStore) Delete

func (s *SessionStore) Delete(key interface{}) error

func (*SessionStore) Get

func (s *SessionStore) Get(key interface{}) interface{}

the content about the system.

func (*SessionStore) SessionID

func (s *SessionStore) SessionID() string

func (*SessionStore) Set

func (s *SessionStore) Set(key, value interface{}) error

type Values

type Values struct {
	Country string `json:"country"`
	City    string `json:"city"`
}

func WhichCountry

func WhichCountry(ip ...string) (values []*Values)

add ip address, return country and city.

Example
v := WhichCountry("173.82.115.125")
for _, b := range v {
	fmt.Println(b.Country, b.City)
	
Output:

美国 洛杉矶

Directories

Path Synopsis
app.go this file has the global functions structs maps slices or anything else.
app.go this file has the global functions structs maps slices or anything else.
deal with pictures.Handling images, such as compression
deal with pictures.Handling images, such as compression

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL