Shorcodes Practice

Built-in Shortcodes
Hudo Shorcodes Practice.
high light
{{< highlight go >}} fmt.Println(“Hello World”) {{< /highlight >}}
|
|
{{< highlight html >}}
This HTML{{< /highlight >}}
|
|
gist
{{< gist kimi0230 ede767a27a0d62b4d458a17d28708995 >}}
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
type Obj struct { | |
name string | |
age int | |
work SubObj | |
} | |
// 深複製: 把參考物件的變數指向複製過的新物件, 而不是原有他被參考的物件 | |
func (r *Obj) DeepClone() *Obj { | |
// 深複製 | |
var obj = new(Obj) | |
obj.work = *(r.work).Clone() | |
obj.age = r.age | |
obj.name = r.name | |
return obj | |
} | |
// 淺複製: 被複製物件的所有變數都含有與原來的物件相同的值, 而所有的對其物件的參考都能指向 | |
func (r *Obj) ShallowClone() *Obj { | |
shallowObj := r | |
shallowObj.name = r.name | |
shallowObj.work = *(r.work).Clone() | |
return shallowObj | |
} | |
type SubObj struct { | |
compnay string | |
} | |
func (w *SubObj) Clone() *SubObj { | |
if w == nil { | |
return nil | |
} | |
shallowObj := w | |
return shallowObj | |
} |
Custom Short Code
{{< myshortcode >}}