api

package
v0.0.0-...-857260f Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2021 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

***************************************** *FileName: file.go *Author: Liu han *Date: 2017-11-24 *Description: File Read & Write Tool ******************************************

Index

Constants

View Source
const (
	USERNAME = "username"
	VIEW     = "view"
	ID       = "id"
)

Variables

View Source
var ConfigFile = "./conf/app.conf"
View Source
var SESSION_MAP = map[string]Session{}

Functions

func AppendBytes

func AppendBytes(filename string, content []byte) error

func AppendString

func AppendString(filename string, content string) error

func DeleteFile

func DeleteFile(filename string) bool

func DeleteSession

func DeleteSession(w http.ResponseWriter, r *http.Request)

func GetMd5String

func GetMd5String(s string) string

生成32位md5字串

func GetUUID

func GetUUID() string

生成Guid字串

func GetUsername

func GetUsername(r *http.Request) string

func HasSession

func HasSession(r *http.Request) bool

func IsFileExist

func IsFileExist(filename string) bool

func Mkdir

func Mkdir(filename string) error

func Mkfile

func Mkfile(filename string) error

func OverwriteBytes

func OverwriteBytes(filename string, content []byte) error

func OverwriteString

func OverwriteString(filename string, content string) error

func ReadBytes

func ReadBytes(filename string) ([]byte, error)

func ReadString

func ReadString(filename string) (string, error)

func SetSession

func SetSession(session Session, w http.ResponseWriter)

Types

type CSV

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

func NewCSV

func NewCSV(path string) *CSV

func (*CSV) Del

func (c *CSV) Del(id string)

func (*CSV) Get

func (c *CSV) Get(id string) Line

func (*CSV) Load

func (c *CSV) Load(path string) error

func (*CSV) Map

func (c *CSV) Map(f func(int, Line) bool)

func (*CSV) Print

func (c *CSV) Print()

func (*CSV) Put

func (c *CSV) Put(line Line)

func (*CSV) Save

func (c *CSV) Save(path string) error

func (*CSV) ToBytes

func (c *CSV) ToBytes() []byte

type Config

type Config struct {
	File string
	Keys map[string]string
}

func (*Config) Bool

func (c *Config) Bool(key string) (bool, error)

func (*Config) DefaultBool

func (c *Config) DefaultBool(key string, defaultval bool) bool

func (*Config) DefaultFloat

func (c *Config) DefaultFloat(key string, defaultval float64) float64

func (*Config) DefaultInt

func (c *Config) DefaultInt(key string, defaultval int) int

func (*Config) DefaultInt64

func (c *Config) DefaultInt64(key string, defaultval int64) int64

func (*Config) DefaultString

func (c *Config) DefaultString(key string, defaultval string) string

func (*Config) DefaultStrings

func (c *Config) DefaultStrings(key string, defaultval []string) []string

func (*Config) Float

func (c *Config) Float(key string) (float64, error)

func (*Config) Int

func (c *Config) Int(key string) (int, error)

func (*Config) Int64

func (c *Config) Int64(key string) (int64, error)

func (*Config) Prase

func (c *Config) Prase() error

func (*Config) String

func (c *Config) String(key string) string

func (*Config) Strings

func (c *Config) Strings(key string) []string

type ConfigInterface

type ConfigInterface interface {
	//Set(key, val string) error   // support section::key type in given key when using ini type.
	String(key string) string    // support section::key type in key string when using ini and json type; Int,Int64,Bool,Float,DIY are same.
	Strings(key string) []string //get string slice
	Int(key string) (int, error)
	Int64(key string) (int64, error)
	Bool(key string) (bool, error)
	Float(key string) (float64, error)
	DefaultString(key string, defaultval string) string      // support section::key type in key string when using ini and json type; Int,Int64,Bool,Float,DIY are same.
	DefaultStrings(key string, defaultval []string) []string //get string slice
	DefaultInt(key string, defaultval int) int
	DefaultInt64(key string, defaultval int64) int64
	DefaultBool(key string, defaultval bool) bool
	DefaultFloat(key string, defaultval float64) float64
}
var AppConfig ConfigInterface

type Key

type Key struct {
	Name  string
	Value string
}

type Line

type Line []string

func (*Line) Id

func (l *Line) Id() string

func (*Line) IsDel

func (l *Line) IsDel() bool

func (*Line) Print

func (l *Line) Print()

func (*Line) Text

func (l *Line) Text() string

func (*Line) ToString

func (l *Line) ToString() string

type Session

type Session map[string]string

func GetSession

func GetSession(r *http.Request) Session

func NewSession

func NewSession(username string, view string) Session

func (Session) GetId

func (s Session) GetId() string

func (Session) GetUsername

func (s Session) GetUsername() string

func (Session) GetView

func (s Session) GetView() string

func (Session) SetId

func (s Session) SetId(uuid string)

func (Session) SetView

func (s Session) SetView(view string)

func (Session) Update

func (s Session) Update()

Jump to

Keyboard shortcuts

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