<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Shelly on Medium]]></title>
        <description><![CDATA[Stories by Shelly on Medium]]></description>
        <link>https://medium.com/@shellytw?source=rss-667a587cba02------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*C6kGfTaXQzOHaYr25fwNug.jpeg</url>
            <title>Stories by Shelly on Medium</title>
            <link>https://medium.com/@shellytw?source=rss-667a587cba02------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 18:30:20 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@shellytw/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Golang learning journey — )A clear guide to when to use Generics]]></title>
            <link>https://shellytw.medium.com/golang-learning-journey-a-clear-guide-to-when-to-use-generics-919bc9989e4f?source=rss-667a587cba02------2</link>
            <guid isPermaLink="false">https://medium.com/p/919bc9989e4f</guid>
            <category><![CDATA[generics]]></category>
            <category><![CDATA[golang]]></category>
            <dc:creator><![CDATA[Shelly]]></dc:creator>
            <pubDate>Mon, 21 Aug 2023 18:23:47 GMT</pubDate>
            <atom:updated>2023-08-21T20:38:30.275Z</atom:updated>
            <content:encoded><![CDATA[<h3>Golang learning journal — (5) A clear guide to when to use Generics</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8d3QzGLJlZngpOvDz-6cFQ.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@geekgunda?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Chinmay B</a> on <a href="https://unsplash.com/photos/fd9mIBluHkA?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><h3>Introduction</h3><p>Hi there! I am Shelly, a non-CS background developer since 2020. This article belongs to my <a href="https://shellytw.medium.com/golang-learning-journal-from-an-ex-javascript-developer-0-background-table-of-contents-c3e202585e47">Golang learning journal series</a>. For all the related articles, you can find the links in the <a href="https://shellytw.medium.com/golang-learning-journal-from-an-ex-javascript-developer-0-background-table-of-contents-c3e202585e47#01f1">table of contents </a>at the very first article of this series.</p><p>In Go, functions, interfaces, and the newly introduced generics enable polymorphism and code reusability. However, how can we know when to use what? Below chart is a simple guideline.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kUU1EZpjcw9REJtjt-VXPw.png" /></figure><p>P.S. “Implementation” means the code logic defined in the function.</p><p>P.S. When the signature is not the same, we simply can not combine two functions. Hence, in the table, we only discuss cases, when signatures are the same.</p><p>Before we dive into the comparison, let’s first look at the syntax of the generics.</p><h3>Syntax with Example</h3><p>The “generic” type should be defined in square brackets [] right after the function name.</p><p>Afterwards, we can use T a placeholder type to represent the concrete/interface input type or concrete/interface output type.</p><h4>First Example</h4><p>[T any] : here, T is so-called type parameter , and T can be ofany type. At the example of a, b , T represents int type. <br>At the example of Hello World , T represents string type.</p><p>By the way, if you are confused about this question:</p><p>Isn’t any equal to interface{} ? Well, it’s not exactly the same. Any is more powerful than interface{} when used in combination of generics .</p><blockquote>The any after the T is a type. any type was introduced alongside generics in Go 1.18, providing a more flexible alternative to interface{} in the context of generic. Unlike interface{}, generic functions using any can operate on <strong>type parameters</strong> without the need for runtime type assertions, leading to safer and more efficient code.&quot;</blockquote><pre>func Swap[T any] (a, b T) (T, T) {<br>  return b, a<br>}<br>func main() {<br>    a, b := 1, 2<br>    x, y := &quot;Hello&quot;, &quot;World&quot;<br>    <br>    a, b = Swap(a, b)<br>    x, y = Swap(x, y)<br>    <br>    fmt.Println(a, b)  // Outputs: 2 1<br>    fmt.Println(x, y)  // Outputs: World Hello<br>}</pre><h4>Second Example</h4><p>[T canShout] : here, T is still a type parameter , and it’s of an interface type canShout .</p><pre>type canShout interface{<br>    Shout() string<br>}<br>type crazyPerson struct {<br>    words string<br>}<br>func (p crazyPerson) Shout() string {<br>    return p.words<br>}<br>type crazyDog struct {<br>    sounds string<br>}<br>func (p crazyDog) Shout() string {<br>    return p.sounds<br>}<br>func PrintShoutingSounds[T canShout](individual T) {<br>  fmt.Println(individual.Shout())<br>}<br>func main() {<br> a := crazyPerson{words: &quot;haha&quot;}<br> PrintShoutingSounds(a) // haha<br> d := crazyDog{sounds: &quot;wonwon&quot;}<br> PrintShoutingSounds(d) // wonwon<br>}</pre><h3>When to use what</h3><p>Now that we understand the syntax and usage of the generics type, let’s come back to the core question: when do we use generics?</p><p>This table gives you a clear answer:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kUU1EZpjcw9REJtjt-VXPw.png" /></figure><p>As we can see from the above table, interface allows developer to decide what happens in the function (the implementation , i.e. the behaviour) freely, as long as the signatures of the functions is the same as the interface’s required functions’ signatures.</p><p>Generics are to be used when implementation is <strong><em>exactly the same</em></strong> but with different input or output types. However, these different input or output types can be of the same “interface” type.</p><p>Hence, the combination of interface and generics is also common. As we see from the example above, PrintShoutingSounds() is a generic function that accepts a type parameter T, which must satisfy the canShout interface.</p><p>Before Generics is released in Go 1.18 in 2022, developer often used interfaces in combination with type assertions or reflect package, to achieve similar outcome as Generics. E.g.</p><pre>func PrintLength(items interface{}) {<br>   nums, ok := items.([]int)<br>   if ok {<br>        fmt.Println(&quot;asserted successfully:&quot;, nums)<br>    } else {<br>        fmt.Println(&quot;Failed to assert&quot;)<br>    }<br>   fmt.Println(len(list))<br>}</pre><p>However, as we see above, we need type assertion (the line nums, ok := items.([]int)is the type assertion) to make sure that the items are a list of integers, or it will panic.</p><p>With generics, we can now build the same function without needing to assert the types:</p><pre>func PrintLength[T any] (items []T) {<br>  fmt.Println(len(items))<br>}</pre><p>Hence, generics assure a more type-safe way.</p><blockquote>Types asserted from interface are checked at runtime, wherease types used with generics are checked at compile-time. This means that when using generics, type mismatches or violations will be caught by the compiler, making our code more type-safe. When we use go run, which first compiles and then runs our program, any type-related issues with generics will be identified immediately during the compilation phase, enabling us to catch and address errors early in the local development process.</blockquote><h3>Four scenarios with examples</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kUU1EZpjcw9REJtjt-VXPw.png" /></figure><ol><li>Signature’s variable types are all the same concrete types, but with different implementations. -&gt; we use interface , as we need to define cal() twice to meet different implementation logics.</li></ol><pre><br>type calculator interface {<br> cal(int) int<br>}<br>type plus1Calculator struct{}<br>type plus2Calculator struct{}<br><br>func (plus1Calculator) cal(input int) int {<br> return input + 1 // different from the implementation of next cal() definition<br>}<br><br>func (plus2Calculator) cal(input int) int {<br> return input + 2<br>}<br><br>func main() {<br> c1 := plus1Calculator{}<br> c2 := plus2Calculator{}<br> fmt.Printf(&quot;%d&quot;, c1.cal(0)) // print out 1<br> fmt.Printf(&quot;%d&quot;, c2.cal(0)) // print out 2<br>}</pre><p>2. Signature’s variable types are all the same concrete types, and with the same implementations. -&gt; we use shared function , as below c1 and c2 both use a shared function cal().</p><pre>type calculator interface {<br> cal(int) int<br>}<br>type times10Calculator struct{}<br><br>func (times10Calculator) cal(input int) int {<br> return input * 10<br>}<br><br>func main() {<br> c1 := times10Calculator{}<br> c2 := times10Calculator{}<br> fmt.Printf(&quot;%d&quot;, c1.cal(1)) // print out 10<br> fmt.Printf(&quot;%d&quot;, c2.cal(1)) // print out 10<br>}</pre><p>3. One of the signature’s variable type is of the different concrete types, and they also have different implementations.</p><p>This is however, by definition impossible, because when it has the same signature, but diff. concrete type, then it can only use “Generics”. <br>However, when using “Generics”, the implementation *should* be the same. <br>Hence, this category will simply belong to the “different signature” group, where we can not really combine the two functions together.</p><p>4.1. Same implementation, but different input/output concrete types who does not belong to the same interface-&gt; usegeneric + concrete type<br>One of the signature’s variable type is of the different concrete types, but they have the same implementations. -&gt; we use generics , like combine() function below.</p><pre>func combine[T any](input1 T, input2 T) {<br> fmt.Println(input1)<br> fmt.Println(input2)<br>}<br><br>func main() {<br> combine(&quot;A&quot;, &quot;B&quot;) // print out A B<br> combine(3, 4)     // print out 3 4<br>}</pre><p>4.2. Same implementation, but different input/output concrete types who belong to the same interface -&gt; use generic + interface type<br>We have demonstrated with thePrintShoutingSounds() example above, where PrintShoutingSounds() is a generic function that accepts a type parameter T, which must satisfy the canShout interface.</p><h3>Restrictions</h3><p>Generics is powerful, but it is also not perfect. Below are the two restrictions I found during the journey using generics.</p><h4>1. Can not access struct field on the type parameter</h4><p>We have learned at, if a type is declared inside [] , it’s called type parameter . However, according to <a href="https://stackoverflow.com/questions/71530811/how-to-access-shared-field-in-structs-in-generics-in-go-1-18-i-get-error-type">this stackoverflow answer which quotes the Go 1.18 release note</a>. The Go compiler does not support accessing a struct field x.fwhere x is of type parameter type even if all types in the type parameter&#39;s type set have a field f. We may remove this restriction in Go 1.19.</p><p>In other words, below, we can not access x.f .</p><pre>type x struct {<br> f string<br>}<br><br>func PrintF[T any](x T) {<br> fmt.Println(x.f) // x.f undefined (type T has no field or method f)<br>}<br>func main() {<br> xInstance := x{f: &quot;Fly&quot;}<br> fmt.Println(xInstance.f) // will print Fly<br> PrintF(xInstance) // error<br>}</pre><blockquote>And it seems like now at 1.21 (as of August, 2023)…this issue is still not fixed.</blockquote><h4>2. More need for manual type inference</h4><p>In the previous examples, we only specify that the types need to be generic type, when we define the functions, because providing the type argument when calling the generic functions is often unnecessary due to type inference.</p><p>However, in some cases, we need to specify types when calling the functions. Otherwise, the go compiler can not know what type it is.</p><p>For example, in the below code, when calling LoadData() , if we write LoadData(&quot;user.json&quot;) , rather than LoadData[User](&quot;user.json&quot;) , then go will have a compiler error.</p><p>However, please note that, the need to specify types or having the compiler infer types isn’t specific only to generics in Go. It’s a broader aspect of the Go language (and statically typed languages in general). However, the prominence of type specification becomes more evident when dealing with generics because of their dynamic nature in terms of type handling.</p><p>Below is an example:</p><pre>// SaveData saves data of any type to a file in JSON format.<br>func SaveData[T any](fileName string, data T) error {<br> bytes, err := json.Marshal(data)<br> if err != nil {<br>  return err<br> }<br> return ioutil.WriteFile(fileName, bytes, 0644)<br>}<br><br>// LoadData loads data from a JSON file into the given type.<br>func LoadData[T any](fileName string) (*T, error) {<br> bytes, err := ioutil.ReadFile(fileName)<br> if err != nil {<br>  return nil, err<br> }<br><br> var result T<br> err = json.Unmarshal(bytes, &amp;result)<br> if err != nil {<br>  return nil, err<br> }<br> return &amp;result, nil<br>}<br><br>type User struct {<br> Name  string<br> Email string<br>}<br><br>func main() {<br> user := User{Name: &quot;Alice&quot;, Email: &quot;alice@example.com&quot;}<br><br> // Save user data to a file<br> err := SaveData(&quot;user.json&quot;, user)<br> if err != nil {<br>  fmt.Println(&quot;Error saving data:&quot;, err)<br>  return<br> }<br><br> // Load user data from a file<br> loadedUser, err := LoadData[User](&quot;user.json&quot;)<br> // loadedUser, err := LoadData(&quot;user.json&quot;)// ./prog.go:51:29: cannot infer T (prog.go:21:15)<br> if err != nil {<br>  fmt.Println(&quot;Error loading data:&quot;, err)<br>  return<br> }<br><br> fmt.Println(&quot;Loaded user:&quot;, *loadedUser)<br>}</pre><p>To clarify further, why do we need to infer the type manually more when it’s generics:</p><ol><li>Standard Types: When dealing with built-in types or user-defined types (e.g., structs), the Go compiler can easily determine the type based on the provided value or context.</li></ol><pre>var x int = 10<br>user := User{Name: &quot;Alice&quot;, Email: &quot;alice@example.com&quot;}</pre><p>Here, x is explicitly typed as int, and user is inferred to be of type User.</p><p>2. Interfaces: With interfaces, the type is determined at runtime based on the concrete type that satisfies the interface. The Go compiler ensures at compile-time that any value assigned to an interface variable satisfies that interface, but the exact type is known only at runtime.</p><pre>var w io.Writer<br>w = os.Stdout</pre><p>Here, the type of w is io.Writer (an interface), but at runtime, its concrete type will be whatever os.Stdout is (in this case, *os.File).</p><p>3. Generics: Generics introduce a new dimension to type specification in Go. Since a generic function or type can operate on multiple types, you sometimes need to specify the type to resolve ambiguity, especially when the type cannot be inferred from the provided arguments.</p><pre>result := LoadData[User](&quot;user.json&quot;)</pre><p>In this case, we’re telling the LoadData function to treat the content of &quot;user.json&quot; as a User type.</p><p>To summarise, while type inference and specification are concepts present throughout Go, generics introduce scenarios where type specification becomes more prominent because a single generic function or type can work with multiple types, and the compiler might need hints to determine the exact type to use.</p><p>Now, I hope this article can help you understand what is generics and when to use it compared to the interface and shared functions.</p><p>See you next time. :)</p><p>Thanks for reading till here. If you found the article helpful, feel free to clap <em>multiple</em> times on the article (one person can clap up to 50 times!), or ❤️ give me some tips following the below link ❤️. Thank you in advance :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=919bc9989e4f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Golang learning journal — Go omitempty tag]]></title>
            <link>https://shellytw.medium.com/golang-learning-journal-go-omitempty-tag-a0f2ee5f7b62?source=rss-667a587cba02------2</link>
            <guid isPermaLink="false">https://medium.com/p/a0f2ee5f7b62</guid>
            <category><![CDATA[json]]></category>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[omitempty]]></category>
            <dc:creator><![CDATA[Shelly]]></dc:creator>
            <pubDate>Tue, 25 Jul 2023 13:30:42 GMT</pubDate>
            <atom:updated>2023-09-05T12:24:39.220Z</atom:updated>
            <content:encoded><![CDATA[<h3>Golang learning journal — (4) Go marshal, unmarshal, and omitempty tag</h3><h4>How to use omitempty struct tag when marshaling</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ncJEGxkJYAwtSlsvxGiwSg.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@kierinsightarchives?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Kier in Sight Archives</a> on <a href="https://unsplash.com/photos/b29z0iltxk4?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><h3>Introduction</h3><p>Hi there! I am Shelly, a non-CS background developer since 2020. This article belongs to my <a href="https://shellytw.medium.com/golang-learning-journal-from-an-ex-javascript-developer-0-background-table-of-contents-c3e202585e47">Golang learning journal series</a>. For all the related articles, you can find the links in the <a href="https://shellytw.medium.com/golang-learning-journal-from-an-ex-javascript-developer-0-background-table-of-contents-c3e202585e47#01f1">table of contents </a>at the very first article of this series.</p><h3>Relationship</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AGIy2w9bUGJKUwiL3Ces7Q.png" /><figcaption>JSON Unmarshal, Marshal, Omitempty</figcaption></figure><p>Before jumping into the definition of what is Unmarshal , Marshal , and omitempty tag, let’s first understand that, in <a href="https://pkg.go.dev/encoding/json">Go’s official documentation</a>, omitempty is mentioned only under Marshal section.</p><blockquote>Hence, omitempty only impacts Marshal, but not Unmarshal.</blockquote><h3>Definition</h3><h4>Go Marshal</h4><p>Go Marshal describes the process of encoding Go struct into JSON-encoded form (in []byte).</p><p>We can use json.Marshal() to replace json.NewEncoder() + encoder.Encode() , below is how you can do it.</p><pre>package main<br><br>import (<br> &quot;bytes&quot;<br> &quot;encoding/json&quot;<br> &quot;fmt&quot;<br>)<br><br>type Person struct {<br> Name string `json:&quot;name&quot;`<br> Age  int    `json:&quot;age&quot;`<br>}<br><br>func main() {<br> p := Person{Name: &quot;Alice&quot;, Age: 30}<br><br> // 1. Using json.Marshal() <br> marshaled, _ := json.Marshal(p)<br> fmt.Println(&quot;Using json.Marshal():&quot;, string(marshaled)) <br> // will print out: {&quot;name&quot;:&quot;Alice&quot;,&quot;age&quot;:30}<br><br> // 2. Using json.NewEncoder().Encode()<br> var buf bytes.Buffer<br> _ = json.NewEncoder(&amp;buf).Encode(p)<br> fmt.Println(&quot;Using json.NewEncoder().Encode():&quot;, buf.String()) <br> // will print out: {&quot;name&quot;:&quot;Alice&quot;,&quot;age&quot;:30}<br>}</pre><h4>Go Unmarshal</h4><p>Go Unmarshal describes the process of decoding JSON-encoded form (in []byte) into Go-struct.</p><p>We can use json.Unmarshal() to replace json.NewEncoder() + encoder.Encode() , below is how you can do it.</p><pre>package main<br><br>import (<br> &quot;bytes&quot;<br> &quot;encoding/json&quot;<br> &quot;fmt&quot;<br> &quot;os&quot;<br>)<br><br>type Person struct {<br> Name string `json:&quot;name&quot;`<br> Age  int    `json:&quot;age&quot;`<br>}<br><br>func main() {<br> jsonBytes := []byte(`{&quot;name&quot;: &quot;Alice&quot;, &quot;age&quot;: 30}`)<br><br> // 1. Using json.Unmarshal<br> var alice1 Person<br> _ = json.Unmarshal(jsonBytes, &amp;alice1)<br> fmt.Println(&quot;Using json.Unmarshal():&quot;, alice1)<br> // will print out `Using json.Unmarshal(): {Alice 30}`<br><br> // 2. Using json.NewDecoder().Decode()<br> var alice2 Person<br> r := bytes.NewReader(jsonBytes)<br> _ = json.NewDecoder(r).Decode(&amp;alice2)<br> fmt.Println(&quot;Using json.NewDecoder().Decode():&quot;, alice2)<br> // will print out `Using json.NewDecoder().Decode(): {Alice 30}`<br>}</pre><h4>Omitempty</h4><p>The last topic is omitempty! We can use omitemptywhen doing Marshal (note: rather thanUnmarshal!). What is the feature of omitempty? Using omitempty will ignore the field when the field’s value is zero value.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AGIy2w9bUGJKUwiL3Ces7Q.png" /><figcaption>JSON Unmarshal, Marshal, Omitempty</figcaption></figure><p>Hence, when encode to JSON bytes, the field that has zero value and is with omitempty tag will be ignored.</p><p>What is zero value? The <strong><em>zero-value</em></strong> for string is empty string &quot;&quot;; for integer is 0, …etc.</p><p>Note that zero value can come from :</p><ol><li>having a key but with zero value e.g. {Age: 30}, or</li><li>do not have a key at all e.g. {}</li></ol><p>Below code snippet will demonstrate the power of omitempty .</p><pre>package main<br><br>import (<br> &quot;encoding/json&quot;<br> &quot;fmt&quot;<br>)<br><br>type PersonWithOmitempty struct {<br> Age int `json:&quot;age,omitempty&quot;`<br>}<br>type PersonNoOmitempty struct {<br> Age int `json:&quot;age&quot;`<br>}<br><br>func main() {<br> aliceExplicit0 := `{&quot;age&quot;:0}`<br> aliceImplicit0 := `{}`<br><br> var aliceExplicitNoAgeWithOmitempty *PersonWithOmitempty<br> _ = json.Unmarshal([]byte(aliceExplicit0), &amp;aliceExplicitNoAgeWithOmitempty)<br> fmt.Printf(&quot;Unmarshal aliceExplicitNoAgeWithOmitempty: %#v\n&quot;, aliceExplicitNoAgeWithOmitempty)<br><br> var aliceImplicitNoAgeWithOmitempty *PersonWithOmitempty<br> _ = json.Unmarshal([]byte(aliceImplicit0), &amp;aliceImplicitNoAgeWithOmitempty)<br> fmt.Printf(&quot;Unmarshal aliceImplicitNoAgeWithOmitempty: %#v\n&quot;, aliceImplicitNoAgeWithOmitempty)<br><br> var aliceExplicitNoAgeNoOmitempty *PersonNoOmitempty<br> _ = json.Unmarshal([]byte(aliceExplicit0), &amp;aliceExplicitNoAgeNoOmitempty)<br> fmt.Printf(&quot;Unmarshal aliceExplicitNoAgeNoOmitempty: %#v\n&quot;, aliceExplicitNoAgeNoOmitempty)<br><br> var aliceImplicitNoAgeNoOmitempty *PersonNoOmitempty<br> _ = json.Unmarshal([]byte(aliceImplicit0), &amp;aliceImplicitNoAgeNoOmitempty)<br> fmt.Printf(&quot;Unmarshal aliceImplicitNoAgeNoOmitempty: %#v\n&quot;, aliceImplicitNoAgeNoOmitempty)<br><br> // Marshal<br> aliceExplicitNoAgeWithOmitEmpty := PersonWithOmitempty{<br>  Age: 0,<br> }<br> aliceImplicitNoAgeWithOmitEmpty := PersonWithOmitempty{}<br> aliceExplicitNoAgeNoOmitEmpty := PersonNoOmitempty{<br>  Age: 0,<br> }<br> aliceImplicitNoAgeNoOmitEmpty := PersonNoOmitempty{}<br> b_aliceExplicitNoAgeWithOmitEmpty, _ := json.Marshal(aliceExplicitNoAgeWithOmitEmpty)<br> b_aliceimplicitNoAgeWithOmitEmpty, _ := json.Marshal(aliceImplicitNoAgeWithOmitEmpty)<br> b_aliceExplicitNoAgeNoOmitEmpty, _ := json.Marshal(aliceExplicitNoAgeNoOmitEmpty)<br> b_aliceimplicitNoAgeNoOmitEmpty, _ := json.Marshal(aliceImplicitNoAgeNoOmitEmpty)<br><br> fmt.Printf(&quot;Marshal %s%s\n&quot;, &quot;aliceExplicitNoAgeWithOmitEmpty: &quot;, string(b_aliceExplicitNoAgeWithOmitEmpty))<br> fmt.Printf(&quot;Marshal %s%s\n&quot;, &quot;aliceImplicitNoAgeWithOmitEmpty: &quot;, string(b_aliceimplicitNoAgeWithOmitEmpty))<br> fmt.Printf(&quot;Marshal %s%s\n&quot;, &quot;aliceExplicitNoAgeNoOmitEmpty: &quot;, string(b_aliceExplicitNoAgeNoOmitEmpty))<br> fmt.Printf(&quot;Marshal %s%s\n&quot;, &quot;aliceImplicitNoAgeNoOmitEmpty: &quot;, string(b_aliceimplicitNoAgeNoOmitEmpty))<br><br>}<br></pre><p>The above code will print out:</p><pre>Unmarshal aliceExplicitNoAgeWithOmitempty: &amp;main.PersonWithOmitempty{Age:0}<br>Unmarshal aliceImplicitNoAgeWithOmitempty: &amp;main.PersonWithOmitempty{Age:0}<br>Unmarshal aliceExplicitNoAgeNoOmitempty: &amp;main.PersonNoOmitempty{Age:0}<br>Unmarshal aliceImplicitNoAgeNoOmitempty: &amp;main.PersonNoOmitempty{Age:0}<br><br>Marshal aliceExplicitNoAgeWithOmitEmpty: {}<br>Marshal aliceImplicitNoAgeWithOmitEmpty: {}<br>Marshal aliceExplicitNoAgeNoOmitEmpty: {&quot;age&quot;:0}<br>Marshal aliceImplicitNoAgeNoOmitEmpty: {&quot;age&quot;:0}</pre><p>Note that, for Unmarshal, 4 results are the same, because omitempty only works together with Marshal , not Unmarshal .</p><p>However, for Marshal, 4 results are NOT the same. The two thats with omitempty tag omits the field “age” completely, whereas the last two that do not haveomitempty tag still show the key “age”.</p><h4>Caveat when using it with zerolog</h4><p>zerolog’s Interface() actually is doing Marshal , according to the documentation:</p><blockquote>Interface adds the field key with i marshaled using reflection.</blockquote><p>Hence, if you try to use zerolog’s log.Info().Interface()to print out the value of a key, the key will disappear when it has omitempty key.</p><ul><li>With<strong><em>out</em></strong> omitempty key, the key revenue will still show up in zerolog:</li></ul><pre>type Request struct {<br> Revenue int `json:&quot;revenue&quot;`<br>}<br><br>var Request Request<br>dec := json.NewDecoder(r.Body)<br>err := dec.Decode(&amp;Request)<br><br>log.Info().Interface(&quot;Request&quot;, Request).Msg(&quot;Request&quot;) // zerolog<br>// &quot;Request&quot;:{&quot;revenue&quot;:0} // here omitempty plays a role, because zerolog use &quot;Marshal&quot;. However &quot;revenue&quot; does not disappear because there is no &quot;omitempty&quot; tag<br><br>fmt.Printf(&quot;Unmarshal: %#v\n&quot;, Request) <br>// &quot;Request&quot;:{&quot;revenue&quot;:0} // here omitempty does NOT play a role. With Unmarshal/Decode, all keys are always preserved.</pre><ul><li>With omitempty key, the key revenue will NOT show up in zerolog:</li></ul><pre>type Request struct {<br> Revenue int `json:&quot;revenue,omitempty&quot;`<br>}<br><br>var Request Request<br>dec := json.NewDecoder(r.Body)<br>err := dec.Decode(&amp;Request)<br><br>log.Info().Interface(&quot;Request&quot;, Request).Msg(&quot;Request&quot;) // zerolog<br>// &quot;Request&quot;:{} // here omitempty plays a role, because zerolog use &quot;Marshal&quot;.<br><br>fmt.Printf(&quot;Unmarshal: %#v\n&quot;, Request) <br>// &quot;Request&quot;:{&quot;revenue&quot;:0} // here omitempty does NOT play a role. With Unmarshal/Decode, all keys are always preserved.</pre><p>Now, I hope this can help you decide when to use omitempty.</p><p>See you next time. :)</p><p>Thanks for reading till here. If you found the article helpful, feel free to clap <em>multiple</em> times on the article (one person can clap up to 50 times!), or ❤️ give me some tips following the below link ❤️. Thank you in advance :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a0f2ee5f7b62" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Golang learning journal from an ex-JavaScript developer — (3) go commands — go get, go install, go…]]></title>
            <link>https://shellytw.medium.com/golang-learning-journal-from-an-ex-javascript-developer-3-go-commands-go-get-go-install-go-5f1604854ef2?source=rss-667a587cba02------2</link>
            <guid isPermaLink="false">https://medium.com/p/5f1604854ef2</guid>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[developer]]></category>
            <category><![CDATA[overchoice]]></category>
            <dc:creator><![CDATA[Shelly]]></dc:creator>
            <pubDate>Mon, 17 Oct 2022 17:37:33 GMT</pubDate>
            <atom:updated>2023-08-21T18:54:51.118Z</atom:updated>
            <content:encoded><![CDATA[<h3>Golang learning journal — (3) go commands — go get, go install, go mod download, go mod tidy — when to use what?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Cc9KTR_hyOP29EeIE_hbyA.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@letyi?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Letizia Bordoni</a> on <a href="https://unsplash.com/s/photos/choice-overload?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><h3>Introduction</h3><p>Hi there! I am Shelly, a non-CS background developer since 2020. This article belongs to my <a href="https://shellytw.medium.com/golang-learning-journal-from-an-ex-javascript-developer-0-background-table-of-contents-c3e202585e47">Golang learning journal series</a>. For all the related articles, you can find the links in the <a href="https://shellytw.medium.com/golang-learning-journal-from-an-ex-javascript-developer-0-background-table-of-contents-c3e202585e47#01f1">table of contents </a>at the very first article of this series.</p><h3>Overchoice</h3><p>For new go developers, it is very confusing to see so many similar commands that can be used to download packages or modules (P.S. — a module is a collection of packages). They are go get , go install , go mod download , and go mod tidy . To understand the differences between them, we first need to understand the history of them.<br>However, before going to the <a href="#179d">lengthy history details</a>, let me first show you a <a href="#5e4d">comparison table</a> and <a href="#775a">summarise when we should use which command</a> in the next section.</p><p>P.S. For some JavaScript developers,go.modis similar to package.json &amp; go.sum is similar to package-lock.json, but NOT exactly. <br>However, as package.json &amp; package-lock.json, both go.mod &amp; go.sum files should be checked into git.</p><h3>Comparison</h3><p>Below is a quick comparison of each command.<br>For the download location, module cachemeans $GOPATH/pkg/mod/cache/download . People also call module cache“local directory storing downloaded modules”. <br>On the other hand, GOBINmeans $GOPATH/bin .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pjkWLhnkForUGHoHuylLjA.png" /><figcaption>Go commands summary table</figcaption></figure><h3>When to use what</h3><p>Let’s start with the most common used commands, and slowly go to the least used ones.</p><p>go mod tidy — this is the most universal used commands. <br> It is very common that, when downloading any non-standard packages, people simply add it manually to the .go file. For example, adding the github.com/gorilla/mux into the import by typing the below line manually at the .go file:</p><pre>import &quot;github.com/gorilla/mux&quot;</pre><p>After adding this line, people usually run go mod tidy , and this command will update both go.mod and go.sum files, adding missing dependencies and removing unused ones. Hence, at your go.mod file, you will now see:</p><pre>require github.com/gorilla/mux v1.8.0</pre><p>P.S. Why do we manually write import &quot;github.com/gorilla/mux&quot;instead of letting the IDE detect and import it? Because most IDEs only recognise <a href="https://pkg.go.dev/std">Go standard libraries</a> (which is located at $GOROOT/src. for example, my fmt is located at /opt/homebrew/Cellar/go/1.19/libexec/src/fmt) and will automatically imports them to the .go file. For example, for standard libraryfmt , you just need to write a function that uses fmt.Println(), then the IDE will automatically put (== automatically import)import &quot;fmt&quot;in the .go file the function is used. However, for non-standard libraries, we would need to write the import ourselves.</p><p>go get — If you just want to update a dependency, rather than traversing through the whole dependency trees to clean it up using go mod tidy, you can run go get to get the specific dependency that you want. e.g.</p><pre>go get -u github.com/gorilla/mux</pre><p>This will add a line at go.mod:</p><pre>require github.com/gorilla/mux v1.8.0 // indirect</pre><p>In the old days, before go module were there, before you can use go mod tidy , go get is also a way to download different versions of a package. However, nowadays, to be honest, add the package name with different version to the import ()block of the .go files and run go mod tidy will do the same thing. Hence, I could imagine that there will be decreasing usage in go get .</p><p>go install — If you want to update a binary, but you don’t want that to mess up / change your go.mod file, then you better run go install ! For example, for updatinggopls package (Go’s official language server), you definitely don’t want it to appear in your go.mod file.</p><p>go mod download — When you first clone a new project, or using a docker. file, you can run/write this command right away, to download dependencies to module cache. <a href="https://github.com/golang/go/issues/26610#issuecomment-411162508">This command seems to be a product of the issue</a> that go mod vendor did not download the packages correctly. It was created in 2018 to fix the issue above for Go v1.11. However, nowadays,go mod tidy will do the same thing. Hence, basically, there is not really need to run this command.</p><h3>History</h3><p>Go modules are introduced in Go 1.11 in 2018, together with a variable called GO111MODULE . <a href="https://maelvls.dev/go111module-everywhere/">This article from Mael</a> illustrates the history quit well.</p><p>In short, there are two ways to deal with modules: the (1) Module-Aware mode, or the (2) GOPATH mode. After Go 1.16, (1) is enabled by default.<br>The go get is a product from the history — the (2) GOPATH mode. The two commands ( go mod downloadand go mod tidy) which withmod (stands for module) in their compositions are the newer (1) Module-Aware mode. What about go install ? It is a nice substitution of the annoying go get , since go get always update the go.mod files but sometimes developers just want to update the binaries without changing the project’s go.mod files. Now, we can use go install to achieve this.</p><h3>Example of using `go mod tidy` &amp; `go get`</h3><p>When you are at a blank project/directory, and run:</p><p>go mod init shelly.com/packages</p><p>You will create a file named go.sum with the following content:</p><pre>module shelly.com/packages</pre><pre>go 1.19</pre><p>Now, write a line which uses the fmt package like below:</p><pre>package main</pre><pre>func main() {<br>   greeting := fmt.Sprintf(&quot;Hello, %s&quot;, &quot;James&quot;) // write this line<br>}</pre><p>You will notice that your IDE, be it GoLand or Visual Studio Code, will automatically add import &quot;fmt&quot; to your file. Exactly as below:</p><pre>package main<br>import &quot;fmt&quot; // this line will appear automatically</pre><pre>func main() {<br>   greeting := fmt.Sprintf(&quot;Hello, %s&quot;, &quot;James&quot;)<br>}</pre><p>Now, add &quot;github.com/gorilla/mux&quot;at main.go like below:</p><pre>package main</pre><pre>import (<br>  &quot;fmt&quot;<br>  &quot;github.com/gorilla/mux&quot; // add this line<br>)</pre><pre>func main() {<br>  greeting := fmt.Sprintf(&quot;Hello, %s&quot;, &quot;James&quot;)<br>  fmt.Println(greeting)<br>}</pre><p>Now run go mod tidy . This will:</p><ol><li>create go.sum file with the following content:</li></ol><pre>github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI=</pre><pre>github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So=</pre><p>2. add require github.com/gorilla/mux v1.8.0 at go.mod file</p><pre>module shelly.com/packages</pre><pre>go 1.19</pre><pre>require github.com/gorilla/mux v1.8.0</pre><p>Now run go get github.com/go-chi/chi@master. This will add the below 2 lines to go.modfile:</p><pre>require github.com/gorilla/mux v1.8.0</pre><pre>require github.com/go-chi/chi v1.5.4 // indirect</pre><p>Plus, adding these lines to go.sum:</p><pre>github.com/go-chi/chi v1.5.4 h1:QHdzF2szwjqVV4wmByUnTcsbIg7UGaQ0tPF2t5GcAIs=</pre><pre>github.com/go-chi/chi v1.5.4/go.mod h1:uaf8YgoFazUOkPBG7fxPftUylNumIev9awIWOENIuEg=</pre><p>Note that //indirect<em> </em>is written after the package because we haven’t import gorilla/mux package anywhere (i.e. we do not have import &quot;github.com/gorilla/mux&quot;written anywhere at any .go files).</p><p>If we now run go mod tidy , then the line with //indirectwill be deleted.</p><p>Sometimes, the //indirect would not be deleted, if the package is used by your direct dependencies.</p><blockquote>Any indirect dependency which is not listed in the <strong>go.mod</strong> file of your direct dependency or if direct dependency doesn’t have a go.mod file, then that dependency will be added to the <strong>go.mod</strong> file with <strong>//indirect </strong>as the suffix. We will see an example of this later in the article to know this better.<br>ref: <a href="https://golangbyexample.com/go-mod-sum-module/">https://golangbyexample.com/go-mod-sum-module/</a></blockquote><p>Hence, it is generally recommended to run go mod tidybefore any commit and release.</p><h3>Miscellaneous</h3><p>There are also other go commands, such as go build&amp; go test . Notice that these 2 commands no longer modify go.mod &amp; go.sum by default.</p><p>go mod tidy are so versatile, and can even be used when upgrading the Go version. When upgrading Go version on existing project, you just need to do the following:</p><ol><li>update go.mod file manually (e.g. change the wording go 1.18 to go 1.19 )</li><li>run go mod tidy</li></ol><p>done!</p><p>Wohoo…that was a long article. How do you feel so far? <br>Furthermore, what is your understanding about these 3 confusing Go commands? Do you have other opinions than me?</p><p>Please leave some comments. Discussions are always enlightening! :)</p><p>Thanks for reading till here. If you found the article helpful, feel free to clap <em>multiple</em> times on the article (one person can clap up to 50 times!), or ❤️ give me some tips following the below link ❤️. Thank you in advance :)</p><p>You are also welcome to clap for this article through liker land, so I can receive some coins on the blockchain! :)</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fbutton.like.co%2Fin%2Fembed%2Fknockout_tw%2Fbutton&amp;display_name=LikeCoin&amp;url=https%3A%2F%2Fbutton.like.co%2Fin%2Flike%2Fknockout_tw&amp;image=https%3A%2F%2Fstorage.googleapis.com%2Flikecoin-foundation.appspot.com%2Flikecoin_store_user_knockout_tw_main%3FGoogleAccessId%3Dfirebase-adminsdk-eyzut%2540likecoin-foundation.iam.gserviceaccount.com%26Expires%3D2430432000%26Signature%3DiPDrRTv%252B5a5vnPeuUeY3W42RipZ78g1RivAHhXkDb%252Bqul%252BsXFCyeciXaWh%252ByUj63OCEa3bwt3D7ZAnirq8FF%252FP87QVUYRSSu17Em6LLTNZiBq%252FqxDpkoIEYFn6QDQxrwlmQFZGkBdKsFCvqw3HeGPbf%252F%252F5I6EAc4PxoUvijKAVlH6CNKYvPJDFJeiwVhUyxWPiM6C%252FO6YzMuYo%252BJTiVUpWMYMxLo3BovU%252FEi9eDfHvlV2A9AS8lo1Ev5SmPfx0NwpiY6MrsFQJhhVScXoa19Mz3QAneO0DWxdzv9t717m%252FzQmYItORWissYlh0XM1kdtyAgscI%252FVeSHDmRhEwIOqQw%253D%253D&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=like" width="360" height="212" frameborder="0" scrolling="no"><a href="https://medium.com/media/3174c44dc31631ca882847b601b9eb0a/href">https://medium.com/media/3174c44dc31631ca882847b601b9eb0a/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5f1604854ef2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Golang learning journal from an ex-JavaScript developer — (2) pointers]]></title>
            <link>https://shellytw.medium.com/golang-learning-journal-from-an-ex-javascript-developer-2-pointers-e3e8d59b6c10?source=rss-667a587cba02------2</link>
            <guid isPermaLink="false">https://medium.com/p/e3e8d59b6c10</guid>
            <category><![CDATA[software]]></category>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[pointers]]></category>
            <dc:creator><![CDATA[Shelly]]></dc:creator>
            <pubDate>Fri, 30 Sep 2022 13:09:56 GMT</pubDate>
            <atom:updated>2023-10-23T07:03:13.973Z</atom:updated>
            <content:encoded><![CDATA[<h3>Golang learning journal — (2) pointers — when to pass by pointer, when to pass by value?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FXB76Uwwb4klBAlwHMWAJQ.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@jannerboy62?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Nick Fewings</a> on <a href="https://unsplash.com/s/photos/arrow?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><h3>Introduction</h3><p>Hi there! I am Shelly, a non-CS background developer since 2020. This article belongs to my <a href="https://shellytw.medium.com/golang-learning-journal-from-an-ex-javascript-developer-0-background-table-of-contents-c3e202585e47">Golang learning journal series</a>. For all the related articles, you can find the links in the <a href="https://shellytw.medium.com/golang-learning-journal-from-an-ex-javascript-developer-0-background-table-of-contents-c3e202585e47#01f1">table of contents </a>at the very first article of this series.</p><h3>Pointers — what are stars (*) and ampersand (&amp;)?</h3><p>Let’s first talk about the two signs that we can’t avoid when it comes to pointers: * and &amp; .</p><h4>Star (*) has 2 meanings</h4><p>(1) <strong>Operator</strong> — when it’s in front of a variable — e.g. below * is in front of a variable <em>p. <br>- </em>This will give you the underlying value of the variable</p><pre>var a = 66<br>p := &amp;a<br>fmt.Println(*p) // the &quot;*&quot; before &quot;p&quot; is an Operator. This will print out 66 (the value)</pre><p>(2) <strong>Signifying that it’s a pointer</strong> — when it’s in front of a type— e.g. below * is in front of a type <em>string.<br>- </em>often used at function declaration</p><pre>// the &quot;*&quot; before &quot;string&quot; is saying that &quot;hey, this is a pointer to a string, not the string itself&quot;<br>func someFunc(pointerA *string) {}</pre><h4><strong>Ampersand (&amp;) has only 1 meaning</strong></h4><p>(1) Operator — when in front of a variable — e.g. below &amp; is in front of a variable<em>a. </em>This will give you the address of the variable.<br><em>- </em>often used at passing value to a function that has pointer as one of it’s inputs’ type</p><pre>var a = 66<br>p := &amp;a // the &quot;&amp;&quot; before &quot;p&quot; is an Operator.<br>fmt.Println(p) // This will print out 0x1400011c028 (the address)</pre><p>Remember that *type is often used in the function declaration? For such a function with *type as input, we need to pass &amp;variable as value when calling that function.</p><pre>func someFunc(pointerA *string) {} // when declaring function</pre><pre>func main() {<br>   var a string<br>   someFunc(&amp;a) // when calling the function<br>}</pre><p>If you accidently passed value using *, i.e. calling someFunc(*a)rather than someFunc(&amp;a), you will get:<br>invalid operation: cannot indirect a(variable of type string).</p><p>Let’s see some example where we can combine * and &amp; :</p><pre>// e.g. 1<br>stringA := &quot;Hello&quot;<br>fmt.Println(*&amp;stringA) // &quot;Hello&quot;</pre><pre>// e.g. 2 when assigning new value to a field of a struct<br>structAPointer = &amp;structA<br>(*structAPointer).attributeX = &quot;New Value&quot;</pre><h4>When to pass by pointer</h4><p>When many functions manipulate the original object. So you don’t need to copy it many times.</p><h4>When to pass by value itself</h4><p>If there is no special needs, go prefers pass by value itself rather than pass by pointer, to avoid extra overhead of <a href="https://tip.golang.org/src/cmd/compile/internal/escape/escape.go">Escape Analysis</a> and crash due to nil pointer.</p><h4>An example of pass by pointer</h4><p>to illustrate how we use all 3 usage explained above:<br>*variable — operator, *type — signifying that it’s a pointer, and &amp;variable — operator.</p><pre>func main() {<br>   var wholeString []string<br>   addString(&amp;wholeString, &quot;new1&quot;) // &amp;wholeString is address<br>   addString(&amp;wholeString, &quot;new2&quot;)<br>   wholeString= append(wholeString, &quot;new3&quot;) // do not need pointer since it&#39;s still in the scope of where wholeString is declared<br>   fmt.Println(&quot;end wholeString: \n&quot;, wholeString)<br>}</pre><pre>func addString (wholeStringPointer *[]string, newString string) {<br>   *wholeStringPointer = append(*wholeStringPointer, newString)<br>   addMoreString(wholeStringPointer)<br>}</pre><pre>func addMoreString (wholeStringPointer *[]string) {<br>   var moreString = &quot;~~~and more&quot;<br>   *wholeStringPointer = append(*wholeStringPointer, moreString)<br>}</pre><pre>func addEvenMoreString(wholeStringPointer *[]string) {<br>  var evenMoreString = &quot;~~~even more\n&quot;<br>  *wholeStringPointer = append(*wholeStringPointer, evenMoreString)<br>}</pre><p>Above code will print out:</p><pre>end wholeString: <br> [new1 ~~~and more ~~~even more<br> new2 ~~~and more ~~~even more<br> new3]</pre><p>Although we are talking about pass by pointer, theoretically, go do not have pass bypointer . Everything is pass byvalue . The pointerin this article means that it’s value is the pointer to an address. Hence, in our example above, since the input of addString() , addMoreString() , and addEvenMoreString()are all*[]string , which is a pointer type. We do use the technique of pass by pointer (the pointer value, aka the address)to change the variable’s underlying value in an upper scope.</p><p>Next article: <a href="https://medium.com/@shellytw/golang-learning-journal-from-an-ex-javascript-developer-3-go-commands-go-get-go-install-go-5f1604854ef2">go commnds — go get, go install, go mod download, go mod tidy — when to use what?</a></p><p>Thanks for reading till here. If you found the article helpful, feel free to clap <em>multiple</em> times on the article (one person can clap up to 50 times!), or ❤️ give me some tips following the below link ❤️. Thank you in advance :)</p><p>You are also welcome to clap for this article through liker land, so I can receive some coins on the blockchain! :)</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fbutton.like.co%2Fin%2Fembed%2Fknockout_tw%2Fbutton&amp;display_name=LikeCoin&amp;url=https%3A%2F%2Fbutton.like.co%2Fin%2Flike%2Fknockout_tw&amp;image=https%3A%2F%2Fstorage.googleapis.com%2Flikecoin-foundation.appspot.com%2Flikecoin_store_user_knockout_tw_main%3FGoogleAccessId%3Dfirebase-adminsdk-eyzut%2540likecoin-foundation.iam.gserviceaccount.com%26Expires%3D2430432000%26Signature%3DiPDrRTv%252B5a5vnPeuUeY3W42RipZ78g1RivAHhXkDb%252Bqul%252BsXFCyeciXaWh%252ByUj63OCEa3bwt3D7ZAnirq8FF%252FP87QVUYRSSu17Em6LLTNZiBq%252FqxDpkoIEYFn6QDQxrwlmQFZGkBdKsFCvqw3HeGPbf%252F%252F5I6EAc4PxoUvijKAVlH6CNKYvPJDFJeiwVhUyxWPiM6C%252FO6YzMuYo%252BJTiVUpWMYMxLo3BovU%252FEi9eDfHvlV2A9AS8lo1Ev5SmPfx0NwpiY6MrsFQJhhVScXoa19Mz3QAneO0DWxdzv9t717m%252FzQmYItORWissYlh0XM1kdtyAgscI%252FVeSHDmRhEwIOqQw%253D%253D&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=like" width="360" height="212" frameborder="0" scrolling="no"><a href="https://medium.com/media/3174c44dc31631ca882847b601b9eb0a/href">https://medium.com/media/3174c44dc31631ca882847b601b9eb0a/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e3e8d59b6c10" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Golang learning journey from an ex-JavaScript developer — (1) go run . and packages]]></title>
            <link>https://shellytw.medium.com/golang-learning-journey-from-an-ex-javascript-developer-1-go-run-and-packages-d107fdff147?source=rss-667a587cba02------2</link>
            <guid isPermaLink="false">https://medium.com/p/d107fdff147</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[developer]]></category>
            <category><![CDATA[go]]></category>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Shelly]]></dc:creator>
            <pubDate>Sun, 18 Sep 2022 11:04:36 GMT</pubDate>
            <atom:updated>2023-08-21T18:55:25.703Z</atom:updated>
            <content:encoded><![CDATA[<h3>Golang learning journal — (1) go run ., go build . and packages</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rLs3KeF8lYr78rEjhQE2-w.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@fempreneurstyledstock?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Leone Venter</a> on <a href="https://unsplash.com/s/photos/packages?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><h3>Introduction</h3><p>Hi there! I am Shelly, a non-CS background developer since 2020. This article belongs to my <a href="https://shellytw.medium.com/golang-learning-journal-from-an-ex-javascript-developer-0-background-table-of-contents-c3e202585e47">Golang learning journal series</a>. For all the related articles, you can find the links in the <a href="https://shellytw.medium.com/golang-learning-journal-from-an-ex-javascript-developer-0-background-table-of-contents-c3e202585e47#01f1">table of contents </a>at the very first article of this series.</p><h3>Why go run main.go shows errors sometimes?</h3><p>You can use</p><pre>go run .</pre><p>to start the go program. However, at your very first time, you may like to try something like this:</p><pre>go run main.go</pre><p>and discovered that the program runs with error like this: <em>undefined: xxx</em>.</p><p>This is because you may have more than 1 file with package main at the first line of the file. The go run . actually runs “all” the files with package main written on it. Hence, the correct way to start the go program is</p><pre>go run .</pre><pre># equals to <br>go run *.go</pre><pre># equals to<br>go run another_file_with_package_main_on_it.go main.go</pre><p>This brings us to the next question. You may now want to add package main just on top of every file, but you will soon discover that you can’t do that if you put those <em>other files</em> in another folder. This has something to do with how Go manages packages.</p><p>By the way, same problem could also happen to go build , if we only specify to build main.go: go build main.go .</p><h3>How do we use packages?</h3><h4>Packages have hierarchies</h4><p>You can’t have the same package name in 2 different directories. Hence, writing package main in different files right under the project root folder is correct. e.g.</p><pre># write `package main` at:<br>./main.go<br>./xx.go<br>./yy.go</pre><p>But the following example will be wrong.</p><pre># write `package main` at:<br>./main.go<br>./folder_x/xx.go<br>./folder_y/yy.go</pre><p>Now read again the <a href="https://go.dev/doc/code#PackagePaths">official document:</a></p><blockquote>A package is a collection of source files in the same directory</blockquote><p>Do you notice the word “<em>same directory</em>”? This is in an official document, but you perhaps need some “experience” to really notice these 2 words.<br>This is also why I say, if it’s your first time, reading pure official documents may not give you the “right” feeling regarding where to focus.</p><h4>Can use functions directly from another file within the same package</h4><p>Furthermore, files that have the same package name can use the function defined at each file, without using the “import” keyword. (e.g. if you have functionX defined at ./xx.go, you can access/use functionX directly at ./main.go without import xx .</p><h4>Can import other packages using an alias or using the default name</h4><p>Let’s say you have a folder structure like this:</p><pre>------ main.go<br>------ hello/hello.go<br>------ go.mod</pre><p>Inside main.go :</p><pre>package main</pre><pre>func main() {...}</pre><p>Inside go.mod :</p><pre>module cards</pre><pre>go 1.19</pre><p>Inside hello/hello.go :</p><pre>package hello</pre><pre>import &quot;fmt&quot;</pre><pre>func Hello() {</pre><pre>   fmt.Printf(&quot;Hello!&quot;)<br>}</pre><pre>func callName() {...}</pre><p>Now you can import hellopackage atmain.go by importing cards/hello like below:</p><pre># at main.go</pre><pre>package main<br>import (<br>    # notice that &quot;cards&quot; is the module name defined at go.mod      <br>    &quot;cards/hello&quot; <br>)</pre><pre>func main() {<br>   hello.Hello()<br>}</pre><p>Notice that we can call Hello() using hello.Hell() , because Go automatically takes the package name defined at go.mod(not the <em>folder</em> name, although oftentimes it&#39;s the same name) as default. If we have named the package name as package hola , then although the file path is ./hello, we will need to call Hello() with hola.Hello() .</p><p>Furthermore, if I want to call hello package with a different name, I can also give it an alias when importing it. Like below, I use xxx an alias for thehello package.</p><pre># at main.go</pre><pre>package main<br>import (<br>    xxx &quot;cards/hello&quot; <br>)</pre><pre>func main() {<br>   xxx.Hello()<br>}</pre><h4>If functions are from other packages, it needs to be capitalized</h4><p>Did you notice that we have named the function inhello.goas Hello() rather than hello()? We capitalize the first letter. In Go, in order to export the function, aka — make the function available by other files that import the package, you need to make the function name’s first character capitalized. For functions that start with a non-capitalized letter, they can’t be exported.</p><p>Next article: <a href="https://shellytw.medium.com/golang-learning-journal-from-an-ex-javascript-developer-2-pointers-e3e8d59b6c10">pointers — when to pass by pointer, when to pass by value?</a></p><p>Thanks for reading till here. If you found the article helpful, feel free to clap <em>multiple</em> times on the article (one person can clap up to 50 times!), or ❤️ give me some tips following the below link ❤️. Thank you in advance :)</p><p>You are also welcome to clap for this article through liker land, so I can receive some coins on the blockchain! :)</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fbutton.like.co%2Fin%2Fembed%2Fknockout_tw%2Fbutton&amp;display_name=LikeCoin&amp;url=https%3A%2F%2Fbutton.like.co%2Fin%2Flike%2Fknockout_tw&amp;image=https%3A%2F%2Fstorage.googleapis.com%2Flikecoin-foundation.appspot.com%2Flikecoin_store_user_knockout_tw_main%3FGoogleAccessId%3Dfirebase-adminsdk-eyzut%2540likecoin-foundation.iam.gserviceaccount.com%26Expires%3D2430432000%26Signature%3DiPDrRTv%252B5a5vnPeuUeY3W42RipZ78g1RivAHhXkDb%252Bqul%252BsXFCyeciXaWh%252ByUj63OCEa3bwt3D7ZAnirq8FF%252FP87QVUYRSSu17Em6LLTNZiBq%252FqxDpkoIEYFn6QDQxrwlmQFZGkBdKsFCvqw3HeGPbf%252F%252F5I6EAc4PxoUvijKAVlH6CNKYvPJDFJeiwVhUyxWPiM6C%252FO6YzMuYo%252BJTiVUpWMYMxLo3BovU%252FEi9eDfHvlV2A9AS8lo1Ev5SmPfx0NwpiY6MrsFQJhhVScXoa19Mz3QAneO0DWxdzv9t717m%252FzQmYItORWissYlh0XM1kdtyAgscI%252FVeSHDmRhEwIOqQw%253D%253D&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=like" width="360" height="212" frameborder="0" scrolling="no"><a href="https://medium.com/media/3174c44dc31631ca882847b601b9eb0a/href">https://medium.com/media/3174c44dc31631ca882847b601b9eb0a/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d107fdff147" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Golang learning journal from an ex-JavaScript developer — (0) Background & Table of Contents]]></title>
            <link>https://shellytw.medium.com/golang-learning-journal-from-an-ex-javascript-developer-0-background-table-of-contents-c3e202585e47?source=rss-667a587cba02------2</link>
            <guid isPermaLink="false">https://medium.com/p/c3e202585e47</guid>
            <category><![CDATA[developer]]></category>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[go]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Shelly]]></dc:creator>
            <pubDate>Sun, 18 Sep 2022 11:03:49 GMT</pubDate>
            <atom:updated>2023-09-05T12:26:38.423Z</atom:updated>
            <content:encoded><![CDATA[<h3>Golang learning journal — (0) Background &amp; Table of Contents</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*h9jkdGd8WGt3w4sXKP8X_w.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@jessbaileydesigns?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Jess Bailey</a> on <a href="https://unsplash.com/s/photos/journal?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><h3>Why do I start this learning journey?</h3><p>Let’s be honest. We are new to Go. We have a job that needs us to code with Go. We don’t have so much time to go through lengthy literature to study Go. Hence, for those who suffer like me, I would love to help you (and the future me) by sharing what I have learned so far on the way to becoming a Go developer.</p><p>I will share with you all the confusion and the “A-Ha” moment I got when learning Go. For stuff that you can find easily online, I would not bother to share. The topics I share here are those that I have to look up multiple Stack Overflow answers, youtube videos, medium articles, or a few official documents so that I can finally get a clear answer. Let’s aim for efficiency. No bullshit. :)</p><p>I plan to put my Go learning journey in this series with a <a href="#01f1">table of contents</a> at the end of this article. I will also keep editing this story once I add more content in the future. Stay tuned!</p><p>Since I am also new to Go, I may not be 100% correct. Hence, feel free to leave a comment if you see something that is wrong/can be improved further. Thanks :)</p><p>The following sections contain:</p><blockquote><a href="#8eaa">- Who am I</a></blockquote><blockquote><a href="#7f05">- Where to start learning Go efficiently</a></blockquote><blockquote><a href="#1e33">- How is Go different from JavaScript</a></blockquote><blockquote><a href="#01f1">- Table of contents for my future journ</a>al</blockquote><h3>Who am I?</h3><p>I am a software developer without a computer science degree (which is actually common — according to the <a href="https://insights.stackoverflow.com/survey/2020#developer-profile-undergraduate-major-professional-developers2">Stack Overflow survey</a>, it’s around 40% of developers around the world as of 2020). Like many non-computer-science-background developers, I start my developer career with JavaScript (JS). After ~2 years as a JS developer who wrote Node.JS &amp; React, I accidentally stepped into the wonderland of go. Due to imposter syndrome, I keep learning, and here is my learning journey with Go.</p><h3>Where to start learning Go efficiently (in 3–4 days)?</h3><p>My starting point was the <a href="https://go.dev/tour/list">tour of go</a>. However, like many official documents, it’s not <em>really</em> beginner friendly. For beginners, you would need some extra background knowledge to understand the “lean” documentation. But since the tour of go wastes no words, I have discovered that I overlooked many sentences when I first time went through this tour.</p><p>My recommendation for starting learning Go would be <a href="https://www.udemy.com/course/go-the-complete-developers-guide/">The Complete Developer’s Guide (Golang) by Stephan Grider on Udemy</a>. I have also purchased <a href="https://www.udemy.com/course/learn-how-to-code/">Learn How To Code: Google’s Go (golang) Programming Language from Todd McLeod</a>. Although I love how Todd speaks and his life philosophy, Stephan’s course is shorter, much more up-to-date, and to the point. I completed Stephan’s course (which is only 83 videos compared to Todd’s course which is 368 videos) within 3–4 days and it’s good enough for me to kick off coding with Go. I was with Todd till video 28, and felt still quite limited in my knowledge about Go. However, I believe that Todd’s 368 videos must have value. I will slowly go through it when I have free time. For kicking off coding for my job, Stephan is definitely enough.</p><h3>How is Go different from JS?</h3><p>Below are some A-ha comparisons that I learned when comparing Go to JavaScript.</p><ul><li>Go does not have “while” loop. It uses also “for” keyword for both JS-equivalent-for-loop and equivalent-while-loop</li><li>Struct is like “Class” in JavaScript</li><li>Map is like “Objects” in JavaScript</li><li>Go does not have inheritance like JavaScript, but go has “composition” which works similarly to inheritance from JavaScript (see liskov substitution principle at <a href="https://www.youtube.com/watch?v=AKdvlr-RzEA">this youtube</a>)</li><li>The JS “Array” is like Go’s “Slices”. Go also have array, but Go’s “Array” is fixed size, whereas its “Slice” is dynamic size and is used much more often in Go</li><li>JS is more FP (functional programming) than OOP (Object Oriented Programming), whereas Go is neither OOP nor FP, but <a href="https://stackoverflow.com/questions/552336/oop-vs-functional-programming-vs-procedural#:~:text=In%20short%20and%20general%2C%20Procedural,you%20can%20understand%20them%20easily.">procedural programming</a>. However, after listening to <a href="https://podcasts.apple.com/us/podcast/might-go-actually-be-oop/id1120964487?i=1000569936861">Might Go actually be OOP? from Go Time: Golang, Software Engineering</a> podcast, I discover that — it’s all about the definition! People may not be wrong when they say Go is OOP. Since people coming from different programming languages have different definition of what is OOP, you need to be open-minded and continue listening! They may know something that you don’t know.</li><li>Go is itself concurrent — but not “parallel”. Differences between concurrent and parallel can be found in this <a href="https://stackoverflow.com/questions/1897993/what-is-the-difference-between-concurrent-programming-and-parallel-programming">Stack Overflow answers</a></li></ul><p>Below are my notes on the journey of learning Go. Feel free to visit the articles if you are interested!</p><h3>Table of Contents</h3><ol><li><a href="https://shellytw.medium.com/golang-learning-journey-from-an-ex-javascript-developer-1-go-run-and-packages-d107fdff147">go run . and folder hierarchies</a></li><li><a href="https://shellytw.medium.com/golang-learning-journal-from-an-ex-javascript-developer-2-pointers-e3e8d59b6c10">pointers — when to pass by pointer, when to pass by value?</a></li><li><a href="https://medium.com/@shellytw/golang-learning-journal-from-an-ex-javascript-developer-3-go-commands-go-get-go-install-go-5f1604854ef2">go commnds — go get, go install, go mod download, go mod tidy — when to use what?</a></li><li><a href="https://shellytw.medium.com/golang-learning-journal-go-omitempty-tag-a0f2ee5f7b62">Go marshal, unmarshal, and omitempty tag</a></li><li><a href="https://shellytw.medium.com/golang-learning-journey-a-clear-guide-to-when-to-use-generics-919bc9989e4f">A clear guide to when to use Generics</a></li></ol><p>Thanks for reading till here. If you found the article helpful, feel free to clap <em>multiple</em> times on the article (one person can clap up to 50 times!), or ❤️ give me some tips following the below link ❤️. Thank you in advance :)</p><p>You are also welcome to clap for this article through liker land, so I can receive some coins on the blockchain! :)</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fbutton.like.co%2Fin%2Fembed%2Fknockout_tw%2Fbutton&amp;display_name=LikeCoin&amp;url=https%3A%2F%2Fbutton.like.co%2Fin%2Flike%2Fknockout_tw&amp;image=https%3A%2F%2Fstorage.googleapis.com%2Flikecoin-foundation.appspot.com%2Flikecoin_store_user_knockout_tw_main%3FGoogleAccessId%3Dfirebase-adminsdk-eyzut%2540likecoin-foundation.iam.gserviceaccount.com%26Expires%3D2430432000%26Signature%3DiPDrRTv%252B5a5vnPeuUeY3W42RipZ78g1RivAHhXkDb%252Bqul%252BsXFCyeciXaWh%252ByUj63OCEa3bwt3D7ZAnirq8FF%252FP87QVUYRSSu17Em6LLTNZiBq%252FqxDpkoIEYFn6QDQxrwlmQFZGkBdKsFCvqw3HeGPbf%252F%252F5I6EAc4PxoUvijKAVlH6CNKYvPJDFJeiwVhUyxWPiM6C%252FO6YzMuYo%252BJTiVUpWMYMxLo3BovU%252FEi9eDfHvlV2A9AS8lo1Ev5SmPfx0NwpiY6MrsFQJhhVScXoa19Mz3QAneO0DWxdzv9t717m%252FzQmYItORWissYlh0XM1kdtyAgscI%252FVeSHDmRhEwIOqQw%253D%253D&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=like" width="360" height="212" frameborder="0" scrolling="no"><a href="https://medium.com/media/3174c44dc31631ca882847b601b9eb0a/href">https://medium.com/media/3174c44dc31631ca882847b601b9eb0a/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c3e202585e47" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[LikeCoin Progress Update 2022.01.17]]></title>
            <link>https://medium.com/likecoin/likecoin-progress-update-2022-01-17-f322a6ad2664?source=rss-667a587cba02------2</link>
            <guid isPermaLink="false">https://medium.com/p/f322a6ad2664</guid>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[weekly-report]]></category>
            <category><![CDATA[likecoin]]></category>
            <dc:creator><![CDATA[Shelly]]></dc:creator>
            <pubDate>Wed, 19 Jan 2022 16:33:38 GMT</pubDate>
            <atom:updated>2022-01-21T05:54:43.691Z</atom:updated>
            <content:encoded><![CDATA[<h4>Airdrop checker is now live. WordPress Gutenberg version plugin is on the way. New Civic Liker version in the discussion.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EGJElWNyYqMU2SZMYx2gPg.png" /></figure><h3>📈 LikeCoin chain Statistics‌</h3><p>(Difference from 2022.01.03)</p><ul><li>Historical data: <a href="https://docs.google.com/spreadsheets/d/16vCOjhdeSwumnB9YBVLEdG-9KjJMRytwzRf6peaVGKs/edit?usp=sharing">https://docs.google.com/spreadsheets/d/16vCOjhdeSwumnB9YBVLEdG-9KjJMRytwzRf6peaVGKs</a></li><li>Number of addresses: 28,478 (+727).</li><li>Number of delegated LIKE: ~540,570,000 (+22,330,000), 50.16% of total supply.</li><li>Number of ISCN records: 2.12 million</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*p9f7eQ0nunwkn5EpN9ER3g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0XxbyJvYQMl1Uf7zXUFFJQ.png" /></figure><h3>⛓ LikeCoin chain Updates</h3><ul><li>Working on the auto-download feature of Cosmovisor. Cosmovisor v1.0 only support auto-download for Cosmos SDK v0.44.3 or later, while we are using v0.42.x, so we are back-porting features in v0.44.3 for auto-download support onto v0.42.x.</li><li>We have updated one of our statesync enabled node to <a href="https://github.com/likecoin/mainnet/commit/5d80d9ecb3ad481c457fd5d00317277a03d43d1b">expose a public IP</a> to allow easier state sync setup.</li></ul><h3>🎯 Product Update</h3><h3>The Metadata Registry: app.like.co</h3><ul><li>Airdrop checker page launch in <a href="https://app.like.co/airdrop/check">app.like.co/airdrop</a>.</li><li>Add view mode toggle, now can check this site on the mobile device.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*m--SfvD3ufWZFBEEhGj2cQ.jpeg" /></figure><h3>WordPress Plugin</h3><ul><li>WordPress Plugin v2.5 is in QA phase, about to finished, which embraces the modern Gutenberg design and leverages <a href="https://developer.wordpress.org/block-editor/reference-guides/slotfills/">Gutenberg SlotFills</a> for building the Sidebar-related components.</li><li>UX/UI design for admin dashboard was completed. Which reorganise and improve settings of the WordPress Plugin.</li></ul><h3>Civic Liker</h3><ul><li>Since Standnews and Hong Kong Citizen News has been forced to close down, we have automatically stopped the Civic Liker subscription to these two Liker IDs and send email notification to the affected users. The number affected composes 50% of the total number of Civic Likers</li><li>Credit card fraud cases are reported during 13–15 Jan and hence we have tightened credit card payment security level to defend from further attacks.</li><li>We have make the decision to move to a new version of Civic Liker, which is more decentralized and less risky. Have been consolidating the requirements. Plan to launch the MVP asap.</li></ul><h3>🔧 Engineering Update</h3><ul><li>We are working with Matters on ISCN integration using OAuth API.</li><li>We are working to improve our Arweave API’s performance, which would improve user experience of app.like.co and WordPress plugin users.</li></ul><h3>Community Update</h3><ul><li>We are now relaying between Desmos network and Osmosis . Now we are relaying between four IBC enabled chains. (LikeCoin, <a href="https://medium.com/u/84035159a8e0">Desmos</a>, Osmosis, <a href="https://medium.com/u/e8cb21d22b0b">Cosmos Network</a>)</li><li>Shoutout to <a href="https://medium.com/u/e264c4e83289">OmniFlix Network</a> where we now have a <a href="https://likecoin.omniflix.co/">community explorer</a> for likers to manage their LIKE, view validators and proposals.</li><li>Congrats to <a href="https://medium.com/u/f7177c539762">BitSongOfficial</a> releasing their <a href="https://wallet.bitsong.io/#/authentication/login">cross-chain wallet</a> and support LikeCoin now!</li></ul><p><strong>This update is brought to you by the Liker Land team.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f322a6ad2664" width="1" height="1" alt=""><hr><p><a href="https://medium.com/likecoin/likecoin-progress-update-2022-01-17-f322a6ad2664">LikeCoin Progress Update 2022.01.17</a> was originally published in <a href="https://medium.com/likecoin">LikeCoin — the DeBook protocol</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[LikeCoin Progress Update 2021.12.20]]></title>
            <link>https://medium.com/likecoin/likecoin-progress-update-2021-12-20-3656ac4fe487?source=rss-667a587cba02------2</link>
            <guid isPermaLink="false">https://medium.com/p/3656ac4fe487</guid>
            <category><![CDATA[weekly-report]]></category>
            <category><![CDATA[likecoin]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[cosmos]]></category>
            <category><![CDATA[airdrop]]></category>
            <dc:creator><![CDATA[Shelly]]></dc:creator>
            <pubDate>Thu, 23 Dec 2021 03:18:42 GMT</pubDate>
            <atom:updated>2025-03-06T05:43:40.393Z</atom:updated>
            <content:encoded><![CDATA[<h4>LikeCoin movement is now a pure DAO. Working on Airdrop &amp; new WordPress Plugin integrating Arweave &amp; Keplr.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*z2PTGac7wdwPpgRL9k5vsQ.png" /></figure><h3>📈 LikeCoin Chain Statistics‌</h3><p>(Difference from 2021.12.06)</p><p><strong>Block Explorer:</strong> <a href="https://dao.like.co/">https://dao.like.co</a></p><ul><li>Historical data: <a href="https://docs.google.com/spreadsheets/d/16vCOjhdeSwumnB9YBVLEdG-9KjJMRytwzRf6peaVGKs/edit?usp=sharing">https://docs.google.com/spreadsheets/d/16vCOjhdeSwumnB9YBVLEdG-9KjJMRytwzRf6peaVGKs/edit?usp=sharing</a></li><li>Number of addresses: 27,245 (+679)</li><li>Number of delegated LIKE: ~482,760,000 (+15,230,000), 45.03% of total supply</li><li>Number of ISCN registered: (1.6 mil)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*K8OfZYW8F0YXJ3rKKHNBRg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*m_IBiiIWfn0Q4hU1LA1QEQ.png" /></figure><h3>⛓ LikeCoin Chain Updates</h3><ul><li>Working on the build process (including reproducible build) and Cosmovisor setup</li></ul><h3>🎯 Product Update</h3><h3>The Metadata Registry: app.like.co</h3><ul><li>Updated the footer bar with providing more information about LikeCoin and airdrop event.</li><li>Added a new entrance on landing page for the upcoming airdrop event.</li></ul><h3>The Metadata Registry: like.co</h3><ul><li>Developing widget for exporting Authcore seed words.</li></ul><h3>WordPress Plugin</h3><ul><li>Arweave-Wordpress integration plugin is available in development version, working on adding direct Keplr support</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ih7YvoyjEit4j-B_0UlYhg.png" /></figure><h3>Liker Land App</h3><ul><li>Released version 0.23.0, this version includes the support of using WalletConnect on <a href="https://app.like.co/">app.like.co</a></li></ul><h3>🔧 Engineering Update</h3><ul><li>Log4J issues patched across our ELK stack.</li><li>Upload to Arweave API now returns an accessible IPFS directory hash when uploading file bundle.</li></ul><h3>LikeCoin Airdrop</h3><ul><li>The UI of the airdrop checker was completed, will launch to the public as soon as everything is ready. Everyone may check their airdrop amount with Cosmos/Osmosis wallet or LikerID soon.</li><li>UX/UI design is moving on to the airdrop claimer, which will guide the eligible user to complete the airdrop missions and claim the LikeCoin airdrop.</li><li>Support querying airdrop reward with Osmosis address or Civic Liker ID.</li><li>Support email subscribing, users can subscribe with email after querying their airdrop reward.</li></ul><h3>Governance</h3><ul><li><a href="https://dao.like.co/proposals/25">Proposal to Fairdrop LikeCoin to the Cosmos Community and Civic Likers</a> (proposal #25) has been passed. Liker Land team is developing the airdrop tool. More details about airdrop will be announced soon.</li><li>LikeCoin Foundation Limited, registered in Hong Kong, has been deregistered as of 2021.12.10. LikeCoin movement is now a pure DAO.</li></ul><h3>kin ko on Twitter: &quot;LikeCoin Foundation Limited, registered in Hong Kong, has been deregistered as of 2021.12.10.@likecoin movement is now a pure DAO. pic.twitter.com/lRepz69Dei / Twitter&quot;</h3><p>LikeCoin Foundation Limited, registered in Hong Kong, has been deregistered as of 2021.12.10.@likecoin movement is now a pure DAO. pic.twitter.com/lRepz69Dei</p><h3>Others</h3><ul><li>Sponsored WordCamp Taipei 2021, met many friends on gather.town. It’s fun! WordPress community definitely need a #DePub solution. LikeCoin can help.</li><li>Met a group of Civic Media and introduced the concept of data archiving and decentralized publishing on web3.</li><li>We are now on <a href="https://app.osmosis.zone/pool/553">Osmosis DEX</a>! Please follow LikeCoin on Twitter to receive the latest listing news. 🚀</li><li>Growing community discussing governance on Discord. Join Discord if you haven’t!</li><li>See the how-two video about staking LikeCoin on <a href="https://stake.like.co/">stake.like.co</a></li><li>Participated in the Cosmos Vega mainnet upgrade</li></ul><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2F7soCRDCGYCw%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D7soCRDCGYCw&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2F7soCRDCGYCw%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/ddb17dd5fbe51dc8389a80f316632441/href">https://medium.com/media/ddb17dd5fbe51dc8389a80f316632441/href</a></iframe><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FnxSy-kEMy0Q%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DnxSy-kEMy0Q&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FnxSy-kEMy0Q%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/d781ceab8ac22679d1444afd9ea489fd/href">https://medium.com/media/d781ceab8ac22679d1444afd9ea489fd/href</a></iframe><p><strong>This update is bought to you by the Liker Land team.</strong></p><p><a href="https://medium.com/@edmondyu"><em>Edmond</em></a><em> (COO), </em><a href="https://medium.com/@JoshKIU"><em>Joshua</em></a><em> (Design Lead), </em><a href="https://github.com/williamchong"><em>William</em></a><em> (CTO), Chung (Blockchain Developer), </em><a href="https://medium.com/@nwingt"><em>David</em></a><em> (Front-end Lead), </em><a href="https://medium.com/@aurorahuang22"><em>Aurora</em></a><em> (Front-end Developer), </em><a href="https://medium.com/@weijun0827"><em>Wei</em></a><em> (Full Stack Developer), </em><a href="https://medium.com/@shellytw"><em>Shelly</em></a><em> (Full Stack Developer), </em><a href="https://medium.com/@phoebepoon"><em>Phoebe</em></a><em> (CEO)</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3656ac4fe487" width="1" height="1" alt=""><hr><p><a href="https://medium.com/likecoin/likecoin-progress-update-2021-12-20-3656ac4fe487">LikeCoin Progress Update 2021.12.20</a> was originally published in <a href="https://medium.com/likecoin">LikeCoin — the DeBook protocol</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[LikeCoin Progress Update 2021.11.22]]></title>
            <link>https://medium.com/likecoin/likecoin-progress-update-2021-11-22-ff2bd1956f3?source=rss-667a587cba02------2</link>
            <guid isPermaLink="false">https://medium.com/p/ff2bd1956f3</guid>
            <category><![CDATA[cosmos]]></category>
            <category><![CDATA[likecoin]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[airdrop]]></category>
            <category><![CDATA[weekly-report]]></category>
            <dc:creator><![CDATA[Shelly]]></dc:creator>
            <pubDate>Wed, 24 Nov 2021 15:00:19 GMT</pubDate>
            <atom:updated>2025-03-06T05:58:28.763Z</atom:updated>
            <content:encoded><![CDATA[<h4>Building stronger integration with Wallet Connect, Arweave, and IBC. Preparing upcoming Airdrop campaign.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sTVy3zMcEsFLC3ntHX7R_A.png" /></figure><h3>LikeCoin chain statistics‌</h3><p>(Difference from 2021.11.08)</p><p><strong>Block Explorer: </strong><a href="https://dao.like.co/">https://dao.like.co</a></p><ul><li>Historical data: <a href="https://docs.google.com/spreadsheets/d/16vCOjhdeSwumnB9YBVLEdG-9KjJMRytwzRf6peaVGKs/edit?usp=sharing">https://docs.google.com/spreadsheets/d/16vCOjhdeSwumnB9YBVLEdG-9KjJMRytwzRf6peaVGKs/edit?usp=sharing</a></li><li>Number of addresses: 26,053 (+602).</li><li>Number of delegated LIKE: ~489,690,000 (-66,020,000), 45.90% of total supply.</li><li>Number of ISCN registered: 1.36 million.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/870/1*fFWsUSXUtozpDQmrCA75yA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/866/1*_vhR_T9g_s0h9LwrCnXMpg.png" /></figure><h3>LikeCoin chain updates</h3><ul><li>Working on procedures on how to create multi-sig wallet and sign with it, which is for community committee management in the future.</li><li>We have upgraded our IBC relayer versions configurations. You can also find recommended configuration for LikeCoin chain in the <a href="https://github.com/cosmos/relayer/tree/main/interchain/likecoin-mainnet-2">cosmos relayer repository</a>.</li></ul><h3>🎯 Product Update</h3><h3>Arweave + ISCN integration</h3><ul><li>User can now upload content file to Arweave, the permanent storage and register ISCN at one-stop on app.like.co, by paying LikeCoin. The integration also solve the IPFS pinning issue by Arweave+IPFS bridge.</li></ul><h3>The Metadata Registry: app.like.co</h3><ul><li>Added entries (Osmosis、Liquid) on both <a href="https://about.like.co/">about.like.co</a> and <a href="https://app.like.co/">app.like.co</a> to allow users to buy or trade LikeCoin more conveniently.</li><li>Improve hint for insufficient balance.</li></ul><h3>WordPress Plugin</h3><ul><li>Integrating Arweave Upload feature to the WordPress Plugin.</li><li>Ongoing integration of React into our plugin’s admin pages.</li><li>Product text (English version) has been updated.</li></ul><h3>Liker Land App</h3><ul><li>Deprecated referral program related UI.</li><li>Implemented PoC of supporting Wallet Connect which will be available to public soon.</li></ul><h3>🔧 Engineering Update</h3><ul><li>LIKE to Arweave API <a href="https://api.docs.like.co/#f4a46850-fe5a-41be-a676-bd1bfdaee001">documentation</a> is available.</li><li>We are working on a <a href="https://github.com/likecoin/likecoin-js/pull/22">js library</a> for integrating LIKE, Arweave, and ISCN in one SDK to allow simple development experience.</li></ul><h3>LikeCoin Airdrop</h3><ul><li>Atom/Osmo holder and Civic Likers are going to receive a LIKE airdrop in our coming campaign.</li><li>An airdrop proposal will submit to the LikeCoin community soon.</li><li>Details, preparation for the airdrop included UX/UI, visual design, promotion and development are in progress.</li></ul><h3>Others</h3><ul><li>We have participated in the <a href="https://explorer.desmos.network/proposals/2">Desmos mainnet upgrade</a> successfully.</li></ul><p><strong>This update is bought to you by the Liker Land team.</strong></p><p><a href="https://medium.com/@edmondyu"><em>Edmond</em></a><em> (COO), </em><a href="https://medium.com/@JoshKIU"><em>Joshua</em></a><em> (Design Lead), </em><a href="https://github.com/williamchong"><em>William</em></a><em> (CTO), Chung (Blockchain Developer), </em><a href="https://medium.com/@weijun0827"><em>Wei</em></a><em> (Full Stack Developer), </em><a href="https://medium.com/@shellytw"><em>Shelly</em></a><em> (Full Stack Developer), </em><a href="https://medium.com/@nwingt"><em>David</em></a><em> (Frontend Lead), </em><a href="https://medium.com/@aurorahuang22"><em>Aurora</em></a><em> (Frontend Developer)</em></p><h4><a href="https://twitter.com/likecoin">Twitter</a> | <a href="https://like.co/">Website</a> | <a href="https://dao.like.co/">Block Explorer</a> | <a href="https://discord.gg/likecoin">Discord</a></h4><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ff2bd1956f3" width="1" height="1" alt=""><hr><p><a href="https://medium.com/likecoin/likecoin-progress-update-2021-11-22-ff2bd1956f3">LikeCoin Progress Update 2021.11.22</a> was originally published in <a href="https://medium.com/likecoin">LikeCoin — the DeBook protocol</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[LikeCoin Progress Update 2021.10.25]]></title>
            <link>https://medium.com/likecoin/likecoin-progress-update-2021-10-25-b3d4da447eaa?source=rss-667a587cba02------2</link>
            <guid isPermaLink="false">https://medium.com/p/b3d4da447eaa</guid>
            <category><![CDATA[likecoin]]></category>
            <category><![CDATA[weekly-report]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[cosmos]]></category>
            <category><![CDATA[dex]]></category>
            <dc:creator><![CDATA[Shelly]]></dc:creator>
            <pubDate>Tue, 26 Oct 2021 15:12:12 GMT</pubDate>
            <atom:updated>2025-03-06T06:01:07.246Z</atom:updated>
            <content:encoded><![CDATA[<h4>IBC enabled. $LIKE on Osmosis.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GoMAXqwWm1hl8y2RothYFA.png" /></figure><h3>LikeCoin chain statistics‌</h3><p>(Difference from 2021.10.11)</p><p><strong>Block Explorer:</strong> <a href="https://dao.like.co/">https://dao.like.co</a></p><ul><li>Historical data: <a href="https://docs.google.com/spreadsheets/d/16vCOjhdeSwumnB9YBVLEdG-9KjJMRytwzRf6peaVGKs/edit?usp=sharing">https://docs.google.com/spreadsheets/d/16vCOjhdeSwumnB9YBVLEdG-9KjJMRytwzRf6peaVGKs/edit?usp=sharing</a></li><li>Number of addresses: 24,689 (+653)</li><li>Number of delegated LIKE: ~570,510,000 (-224,620,000), 53.73% of total supply (most of the unbonding for preparation on liquidity pool)</li><li>We are reviewing migration statistics, so the data is temporary not available</li><li>Number of ISCN registered: 808,128</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/872/1*dNQtGBekyzYl8MCLS54otw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/872/1*xuE4uZte20TBqvsu2u84CQ.png" /></figure><h3>LikeCoin chain updates</h3><ul><li>IBC transfer enabled</li><li>Setup <a href="https://mapofzones.com/zone?period=24&amp;source=likecoin-mainnet-2&amp;tableOrderBy=success&amp;tableOrderSort=desc&amp;testnet=false">IBC channel</a>s with Osmosis and Cosmos Hub respectively</li><li>Setup relayer for the above channels using <a href="https://github.com/informalsystems/ibc-rs">Hermes</a> and <a href="https://github.com/cosmos/relayer">Go relayer</a></li><li><a href="https://github.com/confio/ts-relayer">ts-relayer</a> does not work on Osmosis, we are investigating this, hopefully fix it, PR to the original repo and setup ts-relayer as an alternative relayer for robustness</li><li>Performance of the new stargate API endpoint <a href="https://mainnet-node.like.co/cosmos/tx/v1beta1/txs/">/cosmos/txs</a> has been improved</li><li>Fixed an issue with huge transaction that de-synced our indexer that is serving /txs and /cosmos/txs endpoint</li><li>We have updated Keplr config and exposed additional node endpoint in out <a href="https://github.com/likecoin/mainnet">mainnet repo</a></li></ul><h3>🎯 Product Update</h3><h3>The Metadata Registry: app.like.co</h3><ul><li>Redefined the label name of EXIF data</li><li>Organized the EXIF data and show it on the ISCN detail page</li></ul><h3>WordPress Plugin</h3><ul><li>Integration of admin pages front-end to React framework is finished and in QA phase</li><li>Design of the WordPress plugin was focused on LikeCoin Button and Civic Liker. Both will become Gutenberg blocks in the future, to improve user-friendliness on pages and posts editing</li></ul><h3>Liker Land App</h3><p>Version v0.22.3 will be released this week, this update includes</p><ul><li>Fixed incorrect APR calculation</li></ul><h3>🔧 Engineering Update</h3><ul><li>Applied <a href="https://github.com/likecoin/iscn-js">iscn-js</a> on like-co and iscn-batch-uploader</li><li>Fixed incorrect fee estimation of iscn-batch-uploader</li><li>Working on iscn-arweave-uploader, the script supports batch upload files from a local directory or IPFS to Arweave</li></ul><h3>Others</h3><ul><li>We are now on <a href="https://app.osmosis.zone/pool/553">Osmosis DEX</a>! Please follow LikeCoin on Twitter to recieve the latest listing news. 🚀</li><li>Growing community discussing governance on Discord. Join Discord if you haven’t!</li></ul><p><strong>This update is bought to you by the Liker Land team.</strong></p><p><a href="https://medium.com/@edmondyu"><em>Edmond</em></a><em> (COO), </em><a href="https://medium.com/@JoshKIU"><em>Joshua</em></a><em> (Design Lead), </em><a href="https://github.com/williamchong"><em>William</em></a><em> (CTO), Chung (Blockchain Developer), </em><a href="https://medium.com/@weijun0827"><em>Wei</em></a><em> (Full Stack Developer), </em><a href="https://medium.com/@shellytw"><em>Shelly</em></a><em> (Full Stack Developer), </em><a href="https://medium.com/@nwingt"><em>David</em></a><em> (Frontend Lead), </em><a href="https://medium.com/@aurorahuang22"><em>Aurora</em></a><em> (Frontend Developer)</em></p><h4><a href="https://twitter.com/likecoin">Twitter</a> | <a href="https://like.co/">Website</a> | <a href="https://dao.like.co/">Block Explorer</a> | <a href="https://discord.gg/likecoin">Discord</a></h4><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b3d4da447eaa" width="1" height="1" alt=""><hr><p><a href="https://medium.com/likecoin/likecoin-progress-update-2021-10-25-b3d4da447eaa">LikeCoin Progress Update 2021.10.25</a> was originally published in <a href="https://medium.com/likecoin">LikeCoin — the DeBook protocol</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>