Join table with View in MySQL

CREATE VIEW CharacterWithAccount
AS
SELECT a.id aid,
  c.id cid,
  c.name name,
  a.country country,
  s.name servername
FROM character c
  INNER JOIN account a
    ON c.accountid = a.id
  INNER JOIN server s
    ON a.serverid = s.id
Read More

Log in Go

``` // Setup f, _ := os.OpenFile(“output.log”, os.O_WRONLY|os.O_CREATE|os.O_APPEND, 0644) defer f.Close() log.SetOutput(f)

Read More

More about reflect slice in go

func myFun(model interface{}){
  // Get type
  m := reflect.Indirect(reflect.ValueOf(model))
  type := m.Type()
  
  // Get Child type, create and append
  if t.Kind() == reflect.Slice{
    childType := t.Elem()
    newChild = reflect.ValueOf(reflect.New(reflect.TypeOf(childType)).Interface()).Elem()
    newChild.Field(i).SetInt(0)
    m.Set(reflect.Append(m, newChild))
  }
}
Read More

Create Object and Slice with Reflect

func AnySlice(objType reflect.Type) {
  // create slice
  objArr := reflect.MakeSlice(reflect.SliceOf(objType), 0, 1)
  
  // create object
  obj := reflect.ValueOf(reflect.New(objType).Interface()).Elem()
  obj.Field(0).SetString("Ming")
  obj.FieldByName("Age").SetInt(18)
  
  // append to slice
  objArr.Set(reflect.Append(objArr, obj))
Read More

Cookie in Gin

``` // Set Cookie func (c *Context) SetCookie( name string, // Cookie Name: “Auth” value string, // Value: “f561b193165a076d8a9970dfd4e1a34ddb54ec36” maxAge int, // Second: 3600 path string, // URL Path: “/” domain string, // Domain name: “MyDomain.com” secure bool, // Secure cookie: true httpOnly bool, // non-javascript cookie: true )

Read More

You're up and running!

Next you can update your site name, avatar and other options using the _config.yml file in the root of your repository (shown below).

Read More