<?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 Ramadhan Salman Alfarisi on Medium]]></title>
        <description><![CDATA[Stories by Ramadhan Salman Alfarisi on Medium]]></description>
        <link>https://medium.com/@ramadhansalmanalfarisi8?source=rss-5a0a3d59e083------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*CSoYe9U9sHBPxBbjP__iEg.jpeg</url>
            <title>Stories by Ramadhan Salman Alfarisi on Medium</title>
            <link>https://medium.com/@ramadhansalmanalfarisi8?source=rss-5a0a3d59e083------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 00:16:13 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ramadhansalmanalfarisi8/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[Optimizing Data Search: Choosing Between Array, Hash, and Tree]]></title>
            <link>https://ramadhansalmanalfarisi8.medium.com/optimizing-data-search-choosing-between-array-hash-and-tree-40bf061f288d?source=rss-5a0a3d59e083------2</link>
            <guid isPermaLink="false">https://medium.com/p/40bf061f288d</guid>
            <category><![CDATA[data-structure-algorithm]]></category>
            <category><![CDATA[searching-algorithm]]></category>
            <category><![CDATA[arrays]]></category>
            <category><![CDATA[trees]]></category>
            <category><![CDATA[hash]]></category>
            <dc:creator><![CDATA[Ramadhan Salman Alfarisi]]></dc:creator>
            <pubDate>Sun, 11 Aug 2024 14:46:02 GMT</pubDate>
            <atom:updated>2024-08-11T14:46:57.797Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*9QPNeKstaPgEzvK-bc4osA.jpeg" /><figcaption>Image from <a href="https://imgflip.com/i/8xppo4">https://imgflip.com/i/8xppo4</a></figcaption></figure><h3><strong>Data Structures</strong></h3><p>Data structures are vital in computer programming because they dictate the organization, storage, and manipulation of data in a program. Mastering data structures is crucial for developing algorithms that are both efficient and effective. Specifically in data searching, choosing the right data structure will make the search process faster and more efficient. In this article, we will discuss arrays, hash, and trees as data structures that play a vital role in data searching.</p><h3><strong>Algorithm</strong></h3><p>An algorithm consists of a series of steps to complete a task. The efficiency of a system is significantly impacted by its algorithms. As algorithms become more complex, the system’s performance tends to slow down. Two standard methods for evaluating system performance are <strong>time complexity</strong> and <strong>space complexity</strong>. Time complexity is A metric that indicates how long an algorithm requires to execute, based on the size of the data it processes. while space complexity is A metric that indicates the memory usage of an algorithm, based on the size of the data it processes.</p><h3>Big O Notation</h3><p>Big O Notation is the method to measure how quickly an algorithm works or how much memory it uses as the size of the data increases. Big O is crucial for measuring time complexity and space complexity. There are various Big O notations to describe the complexity of an algorithm, such as O(1), O(n), O(2n), O(n²), dan O(log n).</p><h3>Arrays</h3><p>Arrays are data structures that store elements in a specific order, accessed by an index starting at 0. They are efficient for one-time search operations but become less efficient for repetitive searches due to their O(n) time complexity, where search time increases linearly with the number of elements.</p><pre>func arrayProcess(arrayMap []map[string]any, search int) map[string]any {<br> var res map[string]any<br> for _, arr := range arrayMap {<br>  if arr[&quot;id&quot;] == search {<br>   res = arr<br>   return res<br>  }<br> }<br> return nil<br>}<br><br>func main() {<br> var arrayMap []map[string]any<br> // Populates the arrayMap slice with 5000 map[string]any elements, each with an &quot;id&quot; key<br> // containing a sequential integer value from 1 to 5000, and a &quot;name&quot; key containing<br> // a formatted string in the format &quot;name-{id}&quot;.<br> loopingCount := 5000<br> for i := 1; i &lt;= loopingCount; i++ {<br>  arrayMap = append(arrayMap, map[string]any{&quot;id&quot;: i, &quot;name&quot;: fmt.Sprintf(&quot;name-%d&quot;, i)})<br> }<br> start := time.Now()<br><br> // randInt selects a random integer between 0 and 4999 (inclusive).<br> // res calls the arrayProcess function with the randomly selected integer<br> // and marshals the resulting map[string]any into a JSON string, which is<br> // then logged.<br> randInt := rand.Intn(5000)<br> res := arrayProcess(arrayMap, randInt)<br> json, _ := json.Marshal(res)<br> log.Println(string(json))<br><br> PrintMemUsage()<br> elapsed := time.Since(start)<br> log.Printf(&quot;the process took %v&quot;, elapsed)<br>}</pre><p>The above is a one-time searching algorithm using an array. Below is the result of its memory allocation and performance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/430/1*1A5GavgS3gvFI3xjDMc98g.png" /></figure><p>Now, let’s change the code in the main function to perform repetitive searching like above.</p><pre>func main() {<br> var arrayMap []map[string]any<br> // Populates the arrayMap slice with 5000 map[string]any elements, each with an &quot;id&quot; key<br> // containing a sequential integer value from 1 to 5000, and a &quot;name&quot; key containing<br> // a formatted string in the format &quot;name-{id}&quot;.<br> loopingCount := 5000<br> for i := 1; i &lt;= loopingCount; i++ {<br>  arrayMap = append(arrayMap, map[string]any{&quot;id&quot;: i, &quot;name&quot;: fmt.Sprintf(&quot;name-%d&quot;, i)})<br> }<br> start := time.Now()<br><br> // searchCount iterates through the arrayMap 5000 times, generating a random integer between 0 and 4999 (inclusive)<br> // and passing it to the arrayProcess function to retrieve the corresponding map[string]any element.<br> // The resulting map is then marshaled to JSON and logged.<br> searchCount := 5000<br> for i := 0; i &lt; searchCount; i++ {<br>  randInt := rand.Intn(5000)<br>  res := arrayProcess(arrayMap, randInt)<br>  json, _ := json.Marshal(res)<br>  log.Println(string(json))<br> }<br><br> PrintMemUsage()<br> elapsed := time.Since(start)<br> log.Printf(&quot;the process took %v&quot;, elapsed)<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/443/1*F4QxuVY6diYNdJ8RA1Vuuw.png" /></figure><h3>Trees</h3><p>Trees are hierarchical data structures with nodes connected by edges, where the root is the top node, and leaves have no children. They are commonly used in file systems, databases, and decision-making processes. Trees, like binary and binary search trees, offer better performance than arrays for repetitive searches due to their O(log n) time complexity. However, they are slower for one-time searches and have higher space complexity O(2n) because each node can have two child nodes.</p><pre>package main<br><br>import &quot;fmt&quot;<br><br>// Node represents a single node in the tree<br>type Node struct {<br> value  int<br> left   *Node<br> right  *Node<br> object map[string]any<br>}<br><br>// BST represents the binary search tree<br>type BST struct {<br> root        *Node<br> resultOrder *[]map[string]any<br>}<br><br>func CreateBST(array []map[string]any, key string) *BST {<br> bst := &amp;BST{}<br> for _, arr := range array {<br>  bst.Insert(arr[key].(int), arr)<br> }<br> return bst<br>}<br><br>// Insert inserts a new value into the BST<br>func (bst *BST) Insert(value int, object map[string]any) {<br> newNode := &amp;Node{value: value, object: object}<br> if bst.root == nil {<br>  bst.root = newNode<br>  bst.resultOrder = &amp;[]map[string]any{}<br> } else {<br>  insertNode(bst.root, newNode)<br> }<br>}<br><br>func insertNode(node, newNode *Node) {<br> if newNode.value &lt; node.value {<br>  if node.left == nil {<br>   node.left = newNode<br>  } else {<br>   insertNode(node.left, newNode)<br>  }<br> } else {<br>  if node.right == nil {<br>   node.right = newNode<br>  } else {<br>   insertNode(node.right, newNode)<br>  }<br> }<br>}<br><br>// Search searches for a value in the BST<br>func (bst *BST) Search(value int) map[string]any {<br> return searchNode(bst.root, value)<br>}<br><br>func searchNode(node *Node, value int) map[string]any {<br> if node == nil {<br>  return nil<br> }<br> if value &lt; node.value {<br>  return searchNode(node.left, value)<br> } else if value &gt; node.value {<br>  return searchNode(node.right, value)<br> } else {<br>  return node.object<br> }<br>}</pre><p>The above is the code to create a tree data structure. Below is the one-time searching algorithm and its results.</p><pre>func main() {<br> var arrayMap []map[string]any<br> // Populates the arrayMap slice with 5000 map[string]any elements, each with an &quot;id&quot; key<br> // containing a sequential integer value from 1 to 5000, and a &quot;name&quot; key containing<br> // a formatted string in the format &quot;name-{id}&quot;.<br> loopingCount := 5000<br> for i := 1; i &lt;= loopingCount; i++ {<br>  arrayMap = append(arrayMap, map[string]any{&quot;id&quot;: i, &quot;name&quot;: fmt.Sprintf(&quot;name-%d&quot;, i)})<br> }<br> start := time.Now()<br><br> // bst.Search(randInt) searches the binary search tree for the map[string]any element<br> // with an &quot;id&quot; key matching the randomly generated integer randInt. The resulting<br> // map[string]any is then marshaled to JSON and logged.<br> bst := CreateBST(arrayMap, &quot;id&quot;)<br> randInt := rand.Intn(5000)<br> res := bst.Search(randInt)<br> json, _ := json.Marshal(res)<br> log.Println(string(json))<br><br> PrintMemUsage()<br> elapsed := time.Since(start)<br> log.Printf(&quot;the process took %v&quot;, elapsed)<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/427/1*GLVPAAtHcRD0QbrqlZhCGw.png" /></figure><p>Now, let’s change the algorithm to perform repetitive searching.</p><pre>func main() {<br> var arrayMap []map[string]any<br> // Populates the arrayMap slice with 5000 map[string]any elements, each with an &quot;id&quot; key<br> // containing a sequential integer value from 1 to 5000, and a &quot;name&quot; key containing<br> // a formatted string in the format &quot;name-{id}&quot;.<br> loopingCount := 5000<br> for i := 1; i &lt;= loopingCount; i++ {<br>  arrayMap = append(arrayMap, map[string]any{&quot;id&quot;: i, &quot;name&quot;: fmt.Sprintf(&quot;name-%d&quot;, i)})<br> }<br> start := time.Now()<br> bst := CreateBST(arrayMap, &quot;id&quot;)<br> // searchCount iterates through the arrayMap 5000 times, generating a random integer between 0 and 4999 (inclusive)<br> // and passing it to the arrayProcess function to retrieve the corresponding map[string]any element.<br> // The resulting map is then marshaled to JSON and logged.<br> searchCount := 5000<br> for i := 0; i &lt; searchCount; i++ {<br>  randInt := rand.Intn(5000)<br>  res := bst.Search(randInt)<br>  json, _ := json.Marshal(res)<br>  log.Println(string(json))<br> }<br><br> PrintMemUsage()<br> elapsed := time.Since(start)<br> log.Printf(&quot;the process took %v&quot;, elapsed)<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/457/1*fG_D45-kyqQnWGPKabsfGQ.png" /></figure><h3>Hash</h3><p>A hash data structure, commonly implemented as a hash table or hash map, stores key-value pairs for efficient data retrieval. It uses a hash function to compute an index (or hash code) for each key, which determines where the associated value is stored. This allows for fast lookups, insertions, and deletions, typically with an average time complexity of O(1). However, collisions can occur when different keys generate the same index, requiring additional handling to maintain performance.</p><pre>// ArrayToMap converts a slice of maps to a map of maps, using the specified key to index the result.<br>// If the specified key does not exist in the input slice, an error is returned.<br>func ArraytoMap(array []map[string]any, key string) (map[string]map[string]any, error) {<br> _, exist := array[0][key]<br> if !exist {<br>  return nil, fmt.Errorf(&quot;ArrayToMap: key %s is not exist&quot;, key)<br> }<br> var result map[string]map[string]any = map[string]map[string]any{}<br> for _, item := range array {<br>  keyString := fmt.Sprintf(&quot;%v&quot;, item[key])<br>  result[keyString] = item<br> }<br> return result, nil<br>}<br><br>func main() {<br> var arrayMap []map[string]any<br> // Populates the arrayMap slice with 5000 map[string]any elements, each with an &quot;id&quot; key<br> // containing a unique integer value from 1 to 5000, and a &quot;name&quot; key containing a<br> // formatted string in the format &quot;name-{id}&quot;.<br> loopingCount := 5000<br> for i := 1; i &lt;= loopingCount; i++ {<br>  arrayMap = append(arrayMap, map[string]any{&quot;id&quot;: i, &quot;name&quot;: fmt.Sprintf(&quot;name-%d&quot;, i)})<br> }<br><br> start := time.Now()<br><br> // The selected code converts the arrayMap slice to a map using the ArraytoMap function,<br> // then selects a random key from the map, retrieves the corresponding value,<br> // and marshals it to JSON, which is then logged.<br> resMap, _ := ArraytoMap(arrayMap, &quot;id&quot;)<br> randInt := fmt.Sprintf(&quot;%d&quot;, rand.Intn(5000))<br> res := resMap[randInt]<br> json, _ := json.Marshal(res)<br> log.Println(string(json))<br><br> PrintMemUsage()<br> elapsed := time.Since(start)<br> log.Printf(&quot;the process took %v&quot;, elapsed)<br>}</pre><p>The above is a one-time searching algorithm using a hash. Below are the results.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/437/1*S2gXTBrHkkvRwEJXH1PtKg.png" /></figure><p>Next, let’s change it to repetitive searching.</p><pre>func main() {<br> var arrayMap []map[string]any<br> // Populates the arrayMap slice with 5000 map[string]any elements, each with an &quot;id&quot; key<br> // containing a unique integer value from 1 to 5000, and a &quot;name&quot; key containing a<br> // formatted string in the format &quot;name-{id}&quot;.<br> loopingCount := 5000<br> for i := 1; i &lt;= loopingCount; i++ {<br>  arrayMap = append(arrayMap, map[string]any{&quot;id&quot;: i, &quot;name&quot;: fmt.Sprintf(&quot;name-%d&quot;, i)})<br> }<br><br> start := time.Now()<br><br> // ArraytoMap is a helper function that converts a slice of maps to a map where the keys are the values of the specified key in each map.<br> // It takes a slice of maps and a string representing the key to use for the map keys.<br> // It returns the resulting map and an error if any.<br> resMap, _ := ArraytoMap(arrayMap, &quot;id&quot;)<br> searchCount := 5000<br> for i := 0; i &lt; searchCount; i++ {<br>  randInt := fmt.Sprintf(&quot;%d&quot;, rand.Intn(5000))<br>  res := resMap[randInt]<br>  json, _ := json.Marshal(res)<br>  log.Println(string(json))<br> }<br><br> PrintMemUsage()<br> elapsed := time.Since(start)<br> log.Printf(&quot;the process took %v&quot;, elapsed)<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/453/1*9EAJb5Hgsi5mFy4ozP0QPQ.png" /></figure><h3>Summary</h3><p>Arrays are efficient for one-time searches but become slower for repetitive searches due to their O(n) time complexity. Trees, such as binary and binary search trees, provide better performance for repetitive searches with O(log n) time complexity but are slower for one-time searches and have higher space complexity O(2n). Hash data structures, like hash tables, offer fast lookups, insertions, and deletions with O(1) time complexity make the performance is best from others but, same as tree, it is slower than array in one-time searches because there is transform data there. This testing is only valid for definite data search processes. The results may differ when searching for uncertain data, such as finding dates that are earlier or later, or strings that contain certain words, etc.</p><h3>References</h3><p><a href="https://www.w3schools.com/dsa/dsa_intro.php">https://www.w3schools.com/dsa/dsa_intro.php</a></p><p><a href="https://www.geeksforgeeks.org/data-structures/">https://www.geeksforgeeks.org/data-structures/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=40bf061f288d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Optimize Your System: Practical Memory Management Strategies With Garbage Collector]]></title>
            <link>https://ramadhansalmanalfarisi8.medium.com/optimize-your-system-practical-memory-management-strategies-with-gargabe-collector-3a891c4fd13b?source=rss-5a0a3d59e083------2</link>
            <guid isPermaLink="false">https://medium.com/p/3a891c4fd13b</guid>
            <category><![CDATA[memory-management]]></category>
            <category><![CDATA[garbage-collection]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Ramadhan Salman Alfarisi]]></dc:creator>
            <pubDate>Tue, 25 Jun 2024 14:26:00 GMT</pubDate>
            <atom:updated>2026-05-02T07:07:23.949Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/508/1*Ztj8lgZakxqVgftMClOq5g.jpeg" /><figcaption>source : <a href="https://imgflip.com/i/8t79j2">https://imgflip.com/i/8t79j2</a></figcaption></figure><p>In system development, whether it’s for a feature or an endpoint, we are often given deadlines. These deadlines frequently lead us to work hastily, neglecting proper memory management, as long as the main function works. Consequently, when many users access the endpoint or feature simultaneously, a disaster known as a memory leak occurs. Why is it a disaster? Because a memory leak can cause the endpoint or system to crash, which is undoubtedly catastrophic. This issue often happens to software engineers who do not understand the business flow of the feature and lack sufficient experience in handling memory management cases, mostly Junior Software Engineers.</p><p><strong>Memory Leak</strong></p><p>A memory leak happens when a program uses memory but doesn’t release it once it’s done. This particularly happens when creating dynamic objects whose values are allocated in heap memory. In such cases, developers might forget to free up the heap memory by releasing memory for all objects that are no longer referenced by the program. When a memory leak occurs, the system’s memory usage will increase, which can reduce system performance. In the worst-case scenario, the heap memory becomes fully allocated and cannot allocate new objects, causing the system crash. In programming languages like C and C++, memory allocation is done manually, making it harder to manage memory effectively. However, most modern programming languages now use automatic memory allocation with garbage collectors (GC), which helps minimize memory leaks.</p><p><strong>Garbage Collection</strong></p><p>Garbage collection is a memory management feature in programming languages. These languages usually include one or more garbage collectors that automatically release memory allocated to objects that the program no longer needs. Although most programming languages now have garbage collection features, there is still a possibility of memory leaks if memory management is not properly handled during system development. Therefore, here are some strategies to help you avoid memory leaks.</p><p><strong>Be Careful When Handle Concurrent / Parallel Operation</strong></p><p>In development, there are some operations that require us to use concurrency or parallelism to make the response performance of an endpoint faster. For example, when executing multiple queries to a database, these queries may be independent of each other. Independence here means that the result of a previous query is not used as a parameter for the next query. In such cases, we usually use concurrency to operate them. This way, the endpoint’s performance becomes faster. However, we must not become complacent, because concurrency consumes a lot of memory resources, which, if not monitored, can cause the application or service to crash.</p><pre>func createObject(length int) []Object {<br> var arrObj []Object<br> for i := 0; i &lt; length; i++ {<br>  objA := Object{<br>   Id:          i + 1,<br>   ObjectName:  fmt.Sprintf(&quot;objA-%d&quot;, i+1),<br>   ObjectDesc:  fmt.Sprintf(&quot;this ini objA-%d&quot;, i+1),<br>   ObjectValue: rand.Intn(1000),<br>  }<br>  arrObj = append(arrObj, objA)<br> }<br> return arrObj<br>}<br><br>func sequence() {<br> var arrObj []Object<br> var arrObj2 []Object<br> var arrObj3 []Object<br><br> // Create arrObj 1<br> arrObj = createObject(1000000)<br> PrintMemUsage()<br><br> // Create arrObj 2<br> arrObj2 = createObject(1000000)<br> PrintMemUsage()<br><br> // Create arrObj 3<br> arrObj3 = createObject(1000000)<br> PrintMemUsage()<br><br> fmt.Println(len(arrObj))<br><br> fmt.Println(len(arrObj2))<br><br> fmt.Println(len(arrObj3))<br>}<br><br>func main() {<br> sequence()<br>}</pre><p>The above is a simple example of object creation in Go using synchronous or blocking operations. Here is the record of memory consumption from the above operation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/341/1*AXMOuEt_gBmegNlAu369ag.png" /></figure><p>HeapAlloc is a variable that indicates the total heap memory used by the variables in the endpoint. NumGC represents the number of garbage collection cycles that have occurred at that endpoint. As seen in the results above, the garbage collector removes unused objects, and the heap memory reallocates memory to objects from the following variables. This is why there is a change in the amount of allocated memory from stage 1 to stage 2, and then stage 3 has the same amount as stage 2.</p><pre>func createObject(length int) []Object {<br> var arrObj []Object<br> for i := 0; i &lt; length; i++ {<br>  objA := Object{<br>   Id:          i + 1,<br>   ObjectName:  fmt.Sprintf(&quot;objA-%d&quot;, i+1),<br>   ObjectDesc:  fmt.Sprintf(&quot;this ini objA-%d&quot;, i+1),<br>   ObjectValue: rand.Intn(1000),<br>  }<br>  arrObj = append(arrObj, objA)<br> }<br> return arrObj<br>}<br><br>func parallel() {<br> chanObject := make(chan []Object, 3)<br> var wg sync.WaitGroup<br> for i := 0; i &lt; 3; i++ {<br>  wg.Add(1)<br>  go func() {<br>   arrObj := createObject(1000000)<br>   PrintMemUsage()<br>   chanObject &lt;- arrObj<br>   wg.Done()<br>  }()<br> }<br> wg.Wait()<br> close(chanObject)<br> for obj := range chanObject {<br>  fmt.Println(len(obj))<br> }<br><br>}<br><br>func main() {<br> parallel()<br>}</pre><p>The code above is an example of creating objects with parallel operation. And here the memory allocation of the code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/305/1*ILQGuNMXd4_ZBy1IQSLKIQ.png" /></figure><p>The GC cycle count does not increase, indicating that the GC does not manage memory allocation each time an object is created. As a result, the heap memory allocation becomes very large, amounting to three times more than the synchronous process. In this process, it is not uncommon for the application to crash because the heap memory cannot accommodate the objects from the variables.</p><p>One solution to consider is to be cautious when using concurrent or parallel operations. If you need to process a concurrent operation, ensure that the number of objects being allocated in heap memory is not excessive. There are several ways to handle this without removing the concurrent process. First, divide the objects into smaller parts and process them in parallel operations synchronously. Second, minimize the scope of your needs when creating objects.</p><pre>func parallelDevided() {<br> arrQueues := [2]int{1, 2}<br> var wg sync.WaitGroup<br><br> for _, q := range arrQueues {<br>  chanObject := make(chan []Object, q)<br>  for i := 0; i &lt; q; i++ {<br>   wg.Add(1)<br>   go func() {<br>    arrObj := createObject(1000000)<br>    PrintMemUsage()<br>    chanObject &lt;- arrObj<br>    wg.Done()<br>   }()<br>  }<br>  wg.Wait()<br>  close(chanObject)<br>  for obj := range chanObject {<br>   fmt.Println(len(obj))<br>  }<br> }<br><br>}<br><br>func main() {<br> parallelDevided()<br>}</pre><p>The provided code previously implemented my initial recommendation. Here are the memory allocation details for that code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/343/1*SApM3CWYCjxUxdQZuIV09A.png" /></figure><p>Disregarding the specific numeric result provided as an example, in the first part, the function operates on a single variable, resulting in heap memory allocation exclusively for objects from that variable. In the second part, the function concurrently processes two variables, leading to the heap memory clearing objects from the previous variable and allocating objects from the subsequent two variables. This approach is expected to be faster than processing all variables sequentially.</p><p><strong>Reduce Database Query Execution Scope</strong></p><p>A database is an essential element in the development of dynamic systems, storing all necessary data for the system’s operation. However, data retrieval from the database can lead to out-of-memory errors if the heap memory cannot allocate enough space for the variables holding this data. This often happens when large amounts of data are needed, requiring substantial memory resources. An example of this is batch processing raw data into a data warehouse.</p><pre>SELECT created_on, item_id, qty, sub_total, disc, tax, service, grand_total FROM sales WHERE created_on BETWEEN &#39;2024-01-01 17:00:00&#39; AND &#39;2024-01-06 16:59:59&#39;</pre><p>The above query retrieves sales data for the past 7 days. Let’s assume it returns 100,000 records. Generally, the larger the object stored in a variable, the more resources the heap memory needs to allocate. The easiest way to address this problem is by reducing the data scope to limit the amount of data retrieved.</p><pre>SELECT created_on, item_id, qty, sub_total, disc, tax, service, grand_total FROM sales WHERE created_on BETWEEN &#39;2024-01-01 17:00:00&#39; AND &#39;2024-01-02 16:59:59&#39;</pre><p>Currently, the query only retrieves one day’s worth of data. To obtain data for 7 days while reducing the scope, we can use an iterative approach. By running the data retrieval query 7 times with a different date filter each time, we can process each set of data to completion before moving on to the next. This ensures that we effectively manage memory usage by processing each day’s data separately, avoiding the need to combine large datasets at the end. If the worst-case scenario still results in the data consuming too much memory on the heap, use the properties of the table to further reduce the scope. For example, like this</p><pre>SELECT created_on, item_id, qty, sub_total, disc, tax, service, grand_total FROM sales WHERE created_on BETWEEN &#39;2024-01-01 17:00:00&#39; AND &#39;2024-01-02 16:59:59&#39; AND item_id IN (1,2,3)</pre><p>Or you can use pagination features with <strong>limit </strong>and <strong>offset</strong>. The key is to reduce the data scope using the properties available in the table. Not all properties can be used, only those that do not affect the outcome of the data processing.</p><p><strong>Conclusion</strong></p><p>Don’t assume that having a garbage collector means the system is immune to out-of-memory errors. We still need to be cautious in managing variables that store the objects needed by the system and the heap memory that accommodates them. If we are careless, the worst-case scenario is that the system will crash, which can be a disaster for both the software developer and the company. Upgrading RAM should be considered as a last resort because we also need to be aware of the costs involved in upgrading it.</p><p><strong>References</strong></p><p><a href="https://owasp.org/www-community/vulnerabilities/Memory_leak">https://owasp.org/www-community/vulnerabilities/Memory_leak</a></p><p><a href="https://www.techtarget.com/searchstorage/definition/garbage-collection">https://www.techtarget.com/searchstorage/definition/garbage-collection</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3a891c4fd13b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How To Dockerize Your API With Go + PostgreSQL + Gin + Docker]]></title>
            <link>https://ramadhansalmanalfarisi8.medium.com/how-to-dockerize-your-api-with-go-postgresql-gin-docker-9a2b16548520?source=rss-5a0a3d59e083------2</link>
            <guid isPermaLink="false">https://medium.com/p/9a2b16548520</guid>
            <dc:creator><![CDATA[Ramadhan Salman Alfarisi]]></dc:creator>
            <pubDate>Sun, 28 May 2023 13:56:03 GMT</pubDate>
            <atom:updated>2023-05-28T14:13:32.454Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OA8NtBpDFVP0MklYh95H3w.png" /></figure><p>Hello mates, still with me Ramadhan, In this article, i will be share you how to dockerize your API with Go as base language, postgreSQL as database, Gin as web framework, and the core of the materials, Docker as container management. Okay, without further ado, let’s break the code.</p><h4>Docker</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Op4kDY4K4d126AL8ohW4aw.png" /></figure><p>Docker is a containerization platform that allows developers to build, package, and deploy applications in a lightweight, portable, and consistent manner across different environments. It uses a client-server architecture where the Docker client communicates with the Docker daemon to perform operations such as building, running, and distributing Docker images.</p><p>Docker images are created using Dockerfiles, which contain instructions for building an application and its dependencies. By using Docker, developers can avoid the “works on my machine” problem and ensure that their applications run consistently across different environments, from development to production.</p><h4>Install Modules</h4><p>Firstly, we have to install all of the modules are support the API working. Copy these command to install all of modules.</p><pre>go get -u github.com/gin-gonic/gin<br>go get github.com/golang-migrate/migrate/v4<br>go get github.com/lib/pq</pre><p>Url sources :</p><p>Go gin : <a href="https://github.com/gin-gonic/gin">https://github.com/gin-gonic/gin</a></p><p>Go migrate : <a href="https://github.com/golang-migrate/migrate">https://github.com/golang-migrate/migrate</a></p><p>postgreSQL driver : <a href="https://github.com/lib/pq">https://github.com/lib/pq</a></p><h4><strong>Create Database Configuration</strong></h4><p>Next, we need to set the database configuration includes host, username, password, and database name. Create a folder named <em>app, </em>then create a file named <em>config.go. </em>Copy<em> </em>the code below :</p><pre>package app<br><br>var (<br> UNAMEDB string = &quot;postgres&quot;<br> PASSDB string = &quot;postgres123&quot;<br> HOSTDB string = &quot;postgres&quot;<br> DBNAME string = &quot;mangastore&quot;<br>)</pre><h4>Create Database</h4><p>Then, we need to create database using shell command. Then execute it on postgreSQL docker container by copy it to the database initialization entrypoint postgreSQL. Create a folder named <em>dbshell, </em>then create a file named <em>db.sh. </em>You can copy the code below :</p><pre>#!/bin/bash<br>set -e<br>export PGPASSWORD=postgres123;<br>psql -v ON_ERROR_STOP=1 --username &quot;postgres&quot; --dbname &quot;mangastore&quot; &lt;&lt;-EOSQL<br>  CREATE DATABASE mangastore;<br>  GRANT ALL PRIVILEGES ON DATABASE mangastore TO &quot;postgres&quot;;<br>EOSQL</pre><p>That code will be create <em>mangastore </em>database.</p><h4>Create Table Migrations</h4><p>We need to create a table migration. The table will be called <em>manga. </em>We just need to write a create table query on sql file. Those files will be execute by <em>go-migrate </em>module. Create a folder named <em>migrations</em>, then create a file named <em>1_create_table_manga.up.sql </em>located there, then copy the code below.</p><pre>CREATE TABLE IF NOT EXISTS manga(<br>    id BIGSERIAL NOT NULL PRIMARY KEY,<br>    title VARCHAR(255) NOT NULL,<br>    genre VARCHAR(255),<br>    volumes INTEGER,<br>    chapters INTEGER,<br>    author VARCHAR(255)<br>);</pre><p>And a file named <em>1_create_table_manga.down.sql</em>, then copy the code below.</p><pre>DROP TABLE IF EXISTS manga;</pre><h4>Create Database Connection and Routes</h4><p>Next step, we need to create a file named <em>app.go </em>in <em>app </em>folder<em>. </em>This file is used to write a create connection function and create routes function. Copy the code below.</p><pre>package app<br><br>import (<br> &quot;database/sql&quot;<br> &quot;fmt&quot;<br> &quot;log&quot;<br><br> &quot;github.com/gin-gonic/gin&quot;<br> &quot;github.com/ramadhanalfarisi/go-simple-dockerizing/controller&quot;<br>)<br><br>type App struct {<br> DB     *sql.DB<br> Routes *gin.Engine<br>}<br><br>func (a *App) CreateConnection(){<br> connStr := fmt.Sprintf(&quot;postgres://%s:%s@%s/%s?sslmode=disable&quot;, UNAMEDB, PASSDB, HOSTDB, DBNAME)<br> db, err := sql.Open(&quot;postgres&quot;, connStr)<br> if err != nil {<br>  log.Fatal(err)<br> }<br> a.DB = db<br>}<br><br>func (a *App) CreateRoutes() {<br> routes := gin.Default()<br> controller := controller.NewMangaController(a.DB)<br> routes.GET(&quot;/manga&quot;, controller.GetManga)<br> routes.POST(&quot;/manga&quot;, controller.InsertManga)<br> a.Routes = routes<br>}<br><br>func (a *App) Run(){<br> a.Routes.Run(&quot;:8080&quot;)<br>}</pre><p><em>App </em>struct contains database connection and routes. All of the functions will call on main function. <em>CreateConnection </em>function will call to create a database connection. <em>CreateRoutes </em>function will call to create routes of the API. and <em>Run </em>function to run the API services.</p><h4>Create Migration Function</h4><p>To execute all of SQL queries in the <em>migrations </em>folder, we need to create a file named <em>migrate.go </em>in <em>app </em>folder to write migration function to execute all of those. This function will use <em>go-migrate </em>to execute those SQL queries. Copy the code below.</p><pre>package app<br><br>import (<br> &quot;log&quot;<br> &quot;github.com/golang-migrate/migrate/v4&quot;<br> &quot;github.com/golang-migrate/migrate/v4/database/postgres&quot;<br> _ &quot;github.com/golang-migrate/migrate/v4/source/file&quot;<br> _ &quot;github.com/lib/pq&quot;<br>)<br><br>func (a *App) Migrate() {<br> driver, err := postgres.WithInstance(a.DB, &amp;postgres.Config{})<br> if err != nil {<br>  log.Println(err)<br> }<br> m, err := migrate.NewWithDatabaseInstance(<br>  &quot;file://./migrations/&quot;,<br>  &quot;mangastore&quot;, driver)<br> if err != nil {<br>  log.Println(err)<br> }<br> if err := m.Steps(2); err != nil {<br>  log.Println(err)<br> }<br>}</pre><p>This function need the database connection to connect to postgreSQL. It also need to know folder location of SQL queries and database name. This function will call on main function to migrate all of database tables.</p><h4>Create Models</h4><p>We need to create a model to form API responses and requests. Create a folder <em>model</em>, then create a file there named <em>manga.go</em>. Copy the code below.</p><pre>package model<br><br>type Manga struct {<br> Id uint `json:&quot;id&quot;`<br> Title string `json:&quot;title&quot;`<br> Genre string `json:&quot;genre&quot;`<br> Volumes uint8 `json:&quot;volumes&quot;`<br> Chapters uint16 `json:&quot;chapters&quot;`<br> Author string `json:&quot;author&quot;`<br>}<br>type PostManga struct {<br> Title string `json:&quot;title&quot; binding:&quot;required&quot;`<br> Genre string `json:&quot;genre&quot;`<br> Volumes uint8 `json:&quot;volumes&quot;`<br> Chapters uint16 `json:&quot;chapters&quot;`<br> Author string `json:&quot;author&quot;`<br>}</pre><p><em>Manga </em>struct is used to form API responses, while <em>PostManga </em>struct is used to form API requests. <em>binding </em>syntax is used to set validation rules. <em>required </em>means the <em>Title </em>parameter had to fill.</p><h4>Create Repositories</h4><p>Repository is the package is used to manage database command. Usually, the commands are intended for <em>INSERT, SELECT, UPDATE, </em>and <em>DELETE </em>will execute in this package. Create a folder named <em>repository, </em>then create files named <em>manga_interface.go </em>and <em>manga.go </em>there.</p><p><em>manga_interface.go </em>is the repository interface for design the repository architecture. Copy the code below.</p><pre>package repository<br><br>import &quot;github.com/ramadhanalfarisi/go-simple-dockerizing/model&quot;<br><br>type MangaRepositoryInterface interface {<br> SelectManga() []model.Manga<br> InsertManga(post model.PostManga) bool<br>}</pre><p><em>manga.go </em>is the repository for execute all commands to database include <em>INSERT </em>and <em>SELECT. </em>Copy the code below.</p><pre>package repository<br><br>import (<br> &quot;database/sql&quot;<br> &quot;log&quot;<br><br> &quot;github.com/ramadhanalfarisi/go-simple-dockerizing/model&quot;<br>)<br><br>type MangaRepository struct {<br> DB *sql.DB<br>}<br><br>func NewMangaRepository(db *sql.DB) MangaRepositoryInterface {<br> return &amp;MangaRepository{DB: db}<br>}<br><br>// InsertManga implements MangaRepositoryInterface<br>func (m *MangaRepository) InsertManga(post model.PostManga) bool {<br> stmt, err := m.DB.Prepare(&quot;INSERT INTO manga (title, genre, volumes, chapters, author) VALUES ($1, $2, $3, $4, $5)&quot;)<br> if err != nil {<br>  log.Println(err)<br>  return false<br> }<br> defer stmt.Close()<br> _, err2 := stmt.Exec(post.Title, post.Genre, post.Volumes, post.Chapters, post.Author)<br> if err2 != nil {<br>  log.Println(err2)<br>  return false<br> }<br> return true<br>}<br><br>// SelectManga implements MangaRepositoryInterface<br>func (m *MangaRepository) SelectManga() []model.Manga {<br> var result []model.Manga<br> rows, err := m.DB.Query(&quot;SELECT * FROM manga&quot;)<br> if err != nil {<br>  log.Println(err)<br>  return nil<br> }<br> for rows.Next() {<br>  var (<br>   id       uint<br>   title    string<br>   genre    string<br>   volumes  uint8<br>   chapters uint16<br>   author   string<br>  )<br>  err := rows.Scan(&amp;id, &amp;title, &amp;genre, &amp;volumes, &amp;chapters, &amp;author)<br>  if err != nil {<br>   log.Println(err)<br>  } else {<br>   manga := model.Manga{Id: id, Title: title, Genre: genre, Volumes: volumes, Chapters: chapters, Author: author}<br>   result = append(result, manga)<br>  }<br> }<br> return result<br>}</pre><p><em>InsertManga </em>function executes insert SQL command to create a manga data row. While <em>SelectManga </em>function executes select SQL command to get all manga data.</p><h4>Create Controllers</h4><p>Controller is the package is used to connect all packages to get the expected result, then return it as API response. Create a folder named <em>controller, </em>then create files named <em>manga_interface.go </em>and <em>manga.go.</em></p><p><em>manga_interface.go </em>is the controller interface for design the controller architecture. Copy the code below.</p><pre>package controller<br><br>import &quot;github.com/gin-gonic/gin&quot;<br><br>type MangaControllerInterface interface {<br> InsertManga(g *gin.Context)<br> GetManga(g *gin.Context)<br>}</pre><p><em>manga.go </em>is the controller that is used to connect all packages to get the expected result, then return it as API response. Copy the code below.</p><pre>package controller<br><br>import (<br> &quot;database/sql&quot;<br><br> &quot;github.com/gin-gonic/gin&quot;<br> &quot;github.com/ramadhanalfarisi/go-simple-dockerizing/model&quot;<br> &quot;github.com/ramadhanalfarisi/go-simple-dockerizing/repository&quot;<br>)<br><br>type MangaController struct {<br> DB *sql.DB<br>}<br><br>func NewMangaController(db *sql.DB) MangaControllerInterface {<br> return &amp;MangaController{DB: db}<br>}<br><br>// GetManga implements MangaControllerInterface<br>func (m *MangaController) GetManga(g *gin.Context) {<br> db := m.DB<br> repo_manga := repository.NewMangaRepository(db)<br> get_manga := repo_manga.SelectManga()<br> if get_manga != nil {<br>  g.JSON(200, gin.H{&quot;status&quot;: &quot;success&quot;, &quot;data&quot;: get_manga, &quot;msg&quot;: &quot;get manga successfully&quot;})<br> } else {<br>  g.JSON(200, gin.H{&quot;status&quot;: &quot;success&quot;, &quot;data&quot;: nil, &quot;msg&quot;: &quot;get manga successfully&quot;})<br> }<br>}<br><br>// InsertManga implements MangaControllerInterface<br>func (m *MangaController) InsertManga(g *gin.Context) {<br> db := m.DB<br> var post model.PostManga<br> if err := g.ShouldBindJSON(&amp;post); err == nil {<br>  repo_manga := repository.NewMangaRepository(db)<br>  insert := repo_manga.InsertManga(post)<br>  if insert {<br>   g.JSON(200, gin.H{&quot;status&quot;: &quot;success&quot;, &quot;msg&quot;: &quot;insert manga successfully&quot;})<br>  } else {<br>   g.JSON(500, gin.H{&quot;status&quot;: &quot;failed&quot;, &quot;msg&quot;: &quot;insert manga failed&quot;})<br>  }<br> } else {<br>  g.JSON(400, gin.H{&quot;status&quot;: &quot;success&quot;, &quot;msg&quot;: err})<br> }<br>}</pre><p><em>GetManga </em>function requests all manga data from <em>SelectManga </em>function on repository package, then return a json response. While <em>InsertManga </em>catches the requests from json request and validate it. then, insert the data into database with <em>InsertManga </em>function on repository package.</p><h4>Create Main Function</h4><p>Main function will be the function built as an app service. Create a file named <em>main.go </em>on root folder. Copy the code below :</p><pre>package main<br><br>import (<br> &quot;github.com/ramadhanalfarisi/go-simple-dockerizing/app&quot;<br>)<br><br>func main() {<br> var a app.App<br> a.CreateConnection()<br> a.Migrate()<br> a.CreateRoutes()<br> a.Run()<br>}</pre><h4>Create Dockerfile</h4><p>Dockerfile is used to create a docker image of the app service. Create file name <em>Dockerfile </em>on root folder. Copy the code below :</p><pre>FROM golang:1.20<br><br>WORKDIR /app<br><br># pre-copy/cache go.mod for pre-downloading dependencies and only redownloading them in subsequent builds if they change<br>COPY go.mod ./<br>RUN go mod download &amp;&amp; go mod verify<br><br>COPY . .<br>RUN go build -v -o main .<br><br>CMD [&quot;/app/main&quot;]</pre><ul><li><strong>FROM </strong>means the app service use golang version 1.20 as base image</li><li><strong>WORKDIR </strong>means the set the working directory when the app execute any commands</li><li><strong>COPY </strong>will copy the target file to the target destination in container</li><li><strong>RUN </strong>will execute any commands on working directory</li><li><strong>CMD </strong>will run the app service</li></ul><h4>Create Docker Compose</h4><p>Docker compose contains all container configurations. With docker compose, we don’t need to create container many times, just create a file to create many containers with one execution. Create a file named <em>docker-compose.yml. </em>Copy the code below :</p><pre>version: &#39;3&#39;<br><br>services:<br>  postgres:<br>    image: postgres:latest<br>    container_name: postgres_dockerizing<br>    ports:<br>      - 5432:5432<br>    restart: always<br>    environment:<br>      POSTGRES_PASSWORD: postgres123<br>    volumes:<br>      - database_dockerizing:/var/lib/postgresql/data<br>      - ./dbshell:/docker-entrypoint-initdb.d/<br>    networks:<br>      - fullstack<br>  api:<br>    container_name: api_dockerizing<br>    build: .<br>    ports:<br>      - 8080:8080<br>    restart: always<br>    volumes:<br>      - api_volume:/usr/src/app/<br>    depends_on:<br>      - postgres<br>    networks:<br>      - fullstack<br><br>volumes:<br>  database_dockerizing:<br>  api_volume:<br><br>networks:<br>  fullstack:<br>    driver: bridge</pre><h4>Execute App Service</h4><p>To run the app service, we just need to execute docker command. See the command below :</p><pre>docker-compose up --build</pre><h4>Test API</h4><p>Insert Manga API</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*B2HJI0AjyQv52QQQpsXT8A.png" /></figure><p>Get All Manga API</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TrOrVKdulVZAl8uTC48NZw.png" /></figure><p>See the full code in :</p><p>Github : <a href="https://github.com/ramadhanalfarisi/go-simple-dockerizing">https://github.com/ramadhanalfarisi/go-simple-dockerizing</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9a2b16548520" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Create a Simple CRUD (Create, Read, Update, Delete) API With Go + Gin + PostgreSQL]]></title>
            <link>https://ramadhansalmanalfarisi8.medium.com/create-a-simple-crud-api-with-go-gin-postgresql-fbbef32b7423?source=rss-5a0a3d59e083------2</link>
            <guid isPermaLink="false">https://medium.com/p/fbbef32b7423</guid>
            <dc:creator><![CDATA[Ramadhan Salman Alfarisi]]></dc:creator>
            <pubDate>Wed, 26 Apr 2023 08:18:40 GMT</pubDate>
            <atom:updated>2023-04-27T02:31:57.108Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*i61e7BiDNX8yxsp8Q5h8Fg.png" /></figure><p>Hi mates, here i will show y’all how to create a simple CRUD API using Go as base language, Gin as web framework, and PostgreSQL as database.</p><p>You may also wanna see the documentation about the materials :</p><p>Go : <a href="https://go.dev/doc/">https://go.dev/doc/</a></p><p>Gin : <a href="https://gin-gonic.com/docs/">https://gin-gonic.com/docs/</a></p><p>PostgreSQL : <a href="https://www.postgresql.org/docs/">https://www.postgresql.org/docs/</a></p><p>Okay, without further ado, let’s break the codes.</p><h4>Create Database Connection</h4><p>First step, we have to create a database name <em>mangastore. </em>then, create a new table named <em>manga. </em>Copy this SQL query to create the table in pgadmin.</p><pre>CREATE TABLE manga (<br> id BIGSERIAL NOT NULL PRIMARY KEY,<br> title VARCHAR(255) NOT NULL,<br> genre VARCHAR(255) NULL,<br> volumes INT NULL,<br> chapters INT NULL,<br> author VARCHAR(255) NULL<br>)</pre><p>Next, create a connection function. it will be connect our API to database. We need to install PostgreSQL driver module to create the connection function.</p><p>Copy this code, then execute it in your folder’s terminal.</p><pre>go get github.com/lib/pq</pre><p>Now, you have PostgreSQL driver module in your source code. Next, we have to set the configuration of the connection. it will be consist of username, password, host, and database name.</p><p>Create a new folder named <em>db, </em>create a new go file named <em>config.go. </em>After that, copy this code in your <em>config.go </em>file.</p><pre>package db<br><br>var (<br> UNAMEDB string = &quot;postgres&quot;<br> PASSDB string = &quot;postgres&quot;<br> HOSTDB string = &quot;localhost&quot;<br> DBNAME string = &quot;mangastore&quot;<br>)</pre><p>That just example, you can follow it or create your own version.</p><p>Then, create a new file named <em>connectdb.go </em>in <em>db </em>folder. this file used for make database connection function. Copy this code to the file.</p><pre>package db<br><br>import (<br> &quot;database/sql&quot;<br> &quot;fmt&quot;<br> &quot;log&quot;<br><br> _ &quot;github.com/lib/pq&quot;<br>)<br><br>func Connectdb() *sql.DB {<br> connStr := fmt.Sprintf(&quot;postgres://%s:%s@%s/%s?sslmode=disable&quot;, UNAMEDB, PASSDB, HOSTDB, DBNAME)<br> db, err := sql.Open(&quot;postgres&quot;, connStr)<br> if err != nil {<br>  log.Fatal(err)<br> }<br> return db<br>}</pre><p>Description :</p><p><strong>connStr </strong>= Define PostgreSQL connection as string</p><p><strong>sql.Open </strong>= Connect the database with connection string</p><p>This function will return database connection which helps API to manage data in database.</p><h4>Create Model</h4><p>Model used for object that hold data from database. it will be formatted object for API request and response. Create a new folder named <em>model, </em>then, create a new file named <em>manga.go.</em> Copy this code to the file.</p><pre>package model<br><br>type Manga struct {<br> Id uint `json:&quot;id&quot;`<br> Title string `json:&quot;title&quot;`<br> Genre string `json:&quot;genre&quot;`<br> Volumes uint8 `json:&quot;volumes&quot;`<br> Chapters uint16 `json:&quot;chapters&quot;`<br> Author string `json:&quot;author&quot;`<br>}<br><br>type PostManga struct {<br> Title string `json:&quot;title&quot;`<br> Genre string `json:&quot;genre&quot;`<br> Volumes uint8 `json:&quot;volumes&quot;`<br> Chapters uint16 `json:&quot;chapters&quot;`<br> Author string `json:&quot;author&quot;`<br>}<br><br>type MangaUri struct {<br> ID uint `uri:&quot;id&quot; binding:&quot;required,number&quot;`<br>}</pre><p>The<em> Manga </em>model will hold response result from manga table. The <em>PostManga </em>model will hold request data when insert or update data. The <em>MangaUri </em>model will hold uri id request when get one data, update data, and delete data.</p><h4>Create Repository</h4><p>Repository is the file to create database management logic. it may be logic to get data or insert data. Create a new folder named <em>repository, </em>then create a new file named <em>manga_interface.go</em>. Copy this code to <em>manga_interface.go </em>file.</p><pre>package repository<br><br>import &quot;github.com/yourname/go-simple-crud/model&quot;<br><br>type MangaRepositoryInterface interface {<br> InsertManga(model.PostManga) bool<br> GetAllManga() []model.Manga<br> GetOneManga(uint) model.Manga<br> UpdateManga(uint, model.PostManga) model.Manga<br> DeleteManga(uint) bool<br>}</pre><p>This interface file used for design repository file behaviour. There are some functions that abstracted in there includes InsertManga to define insert data logic, GetAllmanga to define get all data logic, GetOneManga to define get data by its id logic, UpdateManga to defineupdate data logic, and DeleteManga to define delete data logic.</p><p>After that, we need to create a new file named <em>manga.go </em>to define all behaviours from its interface. Copy this code to the file.</p><pre>package repository<br><br>import (<br> &quot;database/sql&quot;<br> &quot;log&quot;<br><br> &quot;github.com/yourname/go-simple-crud/model&quot;<br>)<br><br>type MangaRepository struct {<br> Db *sql.DB<br>}<br><br>func NewMangaRepository(db *sql.DB) MangaRepositoryInterface {<br> return &amp;MangaRepository{Db: db}<br>}<br><br>// DeleteManga implements MangaRepositoryInterface<br>func (m *MangaRepository) DeleteManga(id uint) bool {<br> _, err := m.Db.Exec(&quot;DELETE FROM manga WHERE id = $1&quot;, id)<br> if err != nil {<br>  log.Println(err)<br>  return false<br> }<br> return true<br>}<br><br>// GetAllManga implements MangaRepositoryInterface<br>func (m *MangaRepository) GetAllManga() []model.Manga {<br> query, err := m.Db.Query(&quot;SELECT * FROM manga&quot;)<br> if err != nil {<br>  log.Println(err)<br>  return nil<br> }<br> var mangas []model.Manga<br> if query != nil {<br>  for query.Next() {<br>   var (<br>    id       uint<br>    title    string<br>    genre    string<br>    volumes  uint8<br>    chapters uint16<br>    author   string<br>   )<br>   err := query.Scan(&amp;id, &amp;title, &amp;genre, &amp;volumes, &amp;chapters, &amp;author)<br>   if err != nil {<br>    log.Println(err)<br>   }<br>   manga := model.Manga{Id: id, Title: title, Genre: genre, Volumes: volumes, Chapters: chapters, Author: author}<br>   mangas = append(mangas, manga)<br>  }<br> }<br> return mangas<br>}<br><br>// GetOneManga implements MangaRepositoryInterface<br>func (m *MangaRepository) GetOneManga(id uint) model.Manga {<br> query, err := m.Db.Query(&quot;SELECT * FROM manga WHERE id = $1&quot;, id)<br> if err != nil {<br>  log.Println(err)<br>  return model.Manga{}<br> }<br> var manga model.Manga<br> if query != nil {<br>  for query.Next() {<br>   var (<br>    id       uint<br>    title    string<br>    genre    string<br>    volumes  uint8<br>    chapters uint16<br>    author   string<br>   )<br>   err := query.Scan(&amp;id, &amp;title, &amp;genre, &amp;volumes, &amp;chapters, &amp;author)<br>   if err != nil {<br>    log.Println(err)<br>   }<br>   manga = model.Manga{Id: id, Title: title, Genre: genre, Volumes: volumes, Chapters: chapters, Author: author}<br>  }<br> }<br> return manga<br>}<br><br>// InsertManga implements MangaRepositoryInterface<br>func (m *MangaRepository) InsertManga(post model.PostManga) bool {<br> stmt, err := m.Db.Prepare(&quot;INSERT INTO manga(title, genre, volumes, chapters, author) VALUES ($1,$2,$3,$4,$5)&quot;)<br> if err != nil {<br>  log.Println(err)<br>  return false<br> }<br> defer stmt.Close()<br><br> _, err2 := stmt.Exec(post.Title, post.Genre, post.Volumes, post.Chapters, post.Author)<br> if err2 != nil {<br>  log.Println(err2)<br>  return false<br> }<br> return true<br>}<br><br>// UpdateManga implements MangaRepositoryInterface<br>func (m *MangaRepository) UpdateManga(id uint, post model.PostManga) model.Manga {<br> _, err := m.Db.Exec(&quot;UPDATE manga SET title = $1, genre = $2, volumes = $3, chapters = $4, author = $5 WHERE id = $6&quot;, post.Title, post.Genre, post.Volumes, post.Chapters, post.Author, id)<br> if err != nil {<br>  log.Println(err)<br>  return model.Manga{}<br> }<br> return m.GetOneManga(id)<br>}</pre><h4>Create Controller</h4><p>We need to install Gin Web Framework to create the controller. this module used for manage our request and response from API. Copy this command and execute it to your terminal folder.</p><pre>go get -u github.com/gin-gonic/gin</pre><p>Now, we have installed Gin. Then, we need to create controller interface to design controller behaviour. Create <em>controller </em>folder, then create a new file named <em>manga_interface.go. </em>Then copy this code to the file.</p><pre>package controller<br><br>import &quot;github.com/gin-gonic/gin&quot;<br><br>type MangaControllerInterface interface {<br> InsertManga(*gin.Context)<br> GetAllManga(*gin.Context)<br> GetOneManga(*gin.Context)<br> UpdateManga(*gin.Context)<br> DeleteManga(*gin.Context)<br>}</pre><p>Then, we need to define the interface by create a new file named <em>manga.go.</em> Copy this code to the file.</p><pre>package controller<br><br>import (<br> &quot;database/sql&quot;<br><br> &quot;github.com/gin-gonic/gin&quot;<br> &quot;github.com/yourname/go-simple-crud/model&quot;<br> &quot;github.com/yourname/go-simple-crud/repository&quot;<br>)<br><br>type MangaController struct {<br> Db *sql.DB<br>}<br><br>func NewMangaController(db *sql.DB) MangaControllerInterface {<br> return &amp;MangaController{Db: db}<br>}<br><br>// DeleteManga implements MangaControllerInterface<br>func (m *MangaController) DeleteManga(c *gin.Context) {<br> DB := m.Db<br> var uri model.MangaUri<br> if err := c.ShouldBindUri(&amp;uri); err != nil {<br>  c.JSON(400, gin.H{&quot;status&quot;: &quot;failed&quot;, &quot;msg&quot;: err})<br>  return<br> }<br> repository := repository.NewMangaRepository(DB)<br> delete := repository.DeleteManga(uri.ID)<br> if delete {<br>  c.JSON(200, gin.H{&quot;status&quot;: &quot;success&quot;, &quot;msg&quot;: &quot;delete manga successfully&quot;})<br>  return<br> } else {<br>  c.JSON(500, gin.H{&quot;status&quot;: &quot;failed&quot;, &quot;msg&quot;: &quot;delete manga failed&quot;})<br>  return<br> }<br>}<br><br>// GetAllManga implements MangaControllerInterface<br>func (m *MangaController) GetAllManga(c *gin.Context) {<br> DB := m.Db<br> repository := repository.NewMangaRepository(DB)<br> get := repository.GetAllManga()<br> if (get != nil) {<br>  c.JSON(200, gin.H{&quot;status&quot;: &quot;success&quot;, &quot;data&quot;: get, &quot;msg&quot;: &quot;get manga successfully&quot;})<br>  return<br> } else {<br>  c.JSON(200, gin.H{&quot;status&quot;: &quot;success&quot;, &quot;data&quot;: nil, &quot;msg&quot;: &quot;manga not found&quot;})<br>  return<br> }<br>}<br><br>// GetOneManga implements MangaControllerInterface<br>func (m *MangaController) GetOneManga(c *gin.Context) {<br> DB := m.Db<br> var uri model.MangaUri<br> if err := c.ShouldBindUri(&amp;uri); err != nil {<br>  c.JSON(400, gin.H{&quot;status&quot;: &quot;failed&quot;, &quot;msg&quot;: err})<br>  return<br> }<br> repository := repository.NewMangaRepository(DB)<br> get := repository.GetOneManga(uri.ID)<br> if (get != model.Manga{}) {<br>  c.JSON(200, gin.H{&quot;status&quot;: &quot;success&quot;, &quot;data&quot;: get, &quot;msg&quot;: &quot;get manga successfully&quot;})<br>  return<br> } else {<br>  c.JSON(200, gin.H{&quot;status&quot;: &quot;success&quot;, &quot;data&quot;: nil, &quot;msg&quot;: &quot;manga not found&quot;})<br>  return<br> }<br>}<br><br>// InsertManga implements MangaControllerInterface<br>func (m *MangaController) InsertManga(c *gin.Context) {<br> DB := m.Db<br> var post model.PostManga<br> if err := c.ShouldBind(&amp;post); err != nil {<br>  c.JSON(400, gin.H{&quot;status&quot;: &quot;failed&quot;, &quot;msg&quot;: err})<br>  return<br> }<br> repository := repository.NewMangaRepository(DB)<br> insert := repository.InsertManga(post)<br> if insert {<br>  c.JSON(200, gin.H{&quot;status&quot;: &quot;success&quot;, &quot;msg&quot;: &quot;insert manga successfully&quot;})<br>  return<br> } else {<br>  c.JSON(500, gin.H{&quot;status&quot;: &quot;failed&quot;, &quot;msg&quot;: &quot;insert manga failed&quot;})<br>  return<br> }<br>}<br><br>// UpdateManga implements MangaControllerInterface<br>func (m *MangaController) UpdateManga(c *gin.Context) {<br> DB := m.Db<br> var post model.PostManga<br> var uri model.MangaUri<br> if err := c.ShouldBind(&amp;post); err != nil {<br>  c.JSON(400, gin.H{&quot;status&quot;: &quot;failed&quot;, &quot;msg&quot;: err})<br>  return<br> }<br> if err := c.ShouldBindUri(&amp;uri); err != nil {<br>  c.JSON(400, gin.H{&quot;status&quot;: &quot;failed&quot;, &quot;msg&quot;: err})<br>  return<br> }<br> repository := repository.NewMangaRepository(DB)<br> update := repository.UpdateManga(uri.ID,post)<br> if (update != model.Manga{}) {<br>  c.JSON(200, gin.H{&quot;status&quot;: &quot;success&quot;, &quot;data&quot;: update, &quot;msg&quot;: &quot;update manga successfully&quot;})<br>  return<br> } else {<br>  c.JSON(500, gin.H{&quot;status&quot;: &quot;failed&quot;, &quot;data&quot;: nil, &quot;msg&quot;: &quot;update manga failed&quot;})<br>  return<br> }<br>}</pre><h4>Create Routes</h4><p>The routes used to set API endpoint that addressed API for easy use by developer. The routes will be use RESTful concept to make it more effective. Create a new folder named <em>app. </em>Then create a new file named <em>app.go. </em>Copy this code to the file.</p><pre>package app<br><br>import (<br> &quot;database/sql&quot;<br><br> &quot;github.com/gin-gonic/gin&quot;<br> &quot;github.com/yourname/go-simple-crud/controller&quot;<br> &quot;github.com/yourname/go-simple-crud/db&quot;<br>)<br><br>type App struct {<br> DB *sql.DB<br> Router *gin.Engine<br>}<br><br>func (a *App) CreateConnection(){<br> db := db.Connectdb()<br> a.DB = db<br>}<br><br>func (a *App) Routes() {<br> r := gin.Default()<br> controller := controller.NewMangaController(a.DB)<br> r.POST(&quot;/manga&quot;, controller.InsertManga)<br> r.GET(&quot;/manga&quot;, controller.GetAllManga)<br> r.GET(&quot;/manga/:id&quot;, controller.GetOneManga)<br> r.PUT(&quot;/manga/:id&quot;, controller.UpdateManga)<br> r.DELETE(&quot;/manga/:id&quot;, controller.DeleteManga)<br> a.Router = r<br>}<br><br>func (a *App) Run() {<br> a.Router.Run(&quot;:8080&quot;)<br>}</pre><p>Descriptions :</p><p><strong>CreateConnection </strong>: This function used to create database connection for API</p><p><strong>Routes </strong>: This function used to define routes</p><p><strong>Run </strong>: This function used to run all routes, so that the API can be accessed.</p><h4>Defined Main Function</h4><p>This main function will be started in order to API can be accessed. Create a new file in root folder named <em>main.go. </em>Copy this code to the file.</p><pre>package main<br><br>import &quot;github.com/yourname/go-simple-crud/app&quot;<br><br>func main(){<br> var a app.App<br> a.CreateConnection()<br> a.Routes()<br> a.Run()<br>}</pre><h4>Start Go App</h4><p>We need to run <em>main.go </em>to start the Go app. Copy this code, then execute it to your terminal folder.</p><pre>go run main.go</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rZzZ3_IIe4JL2sAfP1_7UA.png" /><figcaption>The result of starting app</figcaption></figure><h4>Test API Using Postman</h4><p><strong>Test Post Manga API</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ty_z9x5gPbntgfNY7I31YA.png" /></figure><p><strong>Test Get All Manga API</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*b9yxok5uRmQZdc2cYeyo4A.png" /></figure><p><strong>Test Get One Manga API</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*u6fAwz6ifAwXJvTjH5MuEA.png" /></figure><p><strong>Test Update Manga API</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rD1DQLe1vx-OgHiRvEsBNg.png" /></figure><p><strong>Test Delete Manga API</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uFCwJhfLeYzVRJV51jWdkQ.png" /></figure><p>We all have learned about how to create a simple CRUD API with Go, Gin, and PostgreSQL. I hope you can be understand all my explanation about them. Keep improve yourself with useful skills for your future. Good Luck!</p><p>Full source code : <a href="https://github.com/ramadhanalfarisi/go-simple-crud">https://github.com/ramadhanalfarisi/go-simple-crud</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fbbef32b7423" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[TikTok Sebagai Media Sosial yang Mempengaruhi Interaksi Sosial]]></title>
            <link>https://ramadhansalmanalfarisi8.medium.com/tiktok-sebagai-media-sosial-yang-mempengaruhi-interaksi-sosial-edd85220716a?source=rss-5a0a3d59e083------2</link>
            <guid isPermaLink="false">https://medium.com/p/edd85220716a</guid>
            <dc:creator><![CDATA[Ramadhan Salman Alfarisi]]></dc:creator>
            <pubDate>Sun, 26 Mar 2023 14:50:04 GMT</pubDate>
            <atom:updated>2023-03-26T14:50:04.457Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*QVwz2evREJEX1PlMnKxcXw.jpeg" /></figure><h4>Latar Belakang TikTok</h4><p>TikTok awalnya diluncurkan di Tiongkok pada September 2016 dengan nama Douyin oleh perusahaan teknologi Tiongkok, ByteDance. Aplikasi ini awalnya hanya tersedia di pasar Tiongkok dan pada awalnya, fokus utama Douyin adalah untuk memberikan platform untuk membagikan video pendek, terutama untuk musik dan tarian.</p><p>Pada 2019, TikTok menjadi aplikasi media sosial paling banyak diunduh di seluruh dunia, dengan lebih dari satu miliar unduhan. TikTok terus tumbuh dan berkembang, dengan pengguna aktif yang terus meningkat di seluruh dunia. TikTok telah menjadi platform yang populer untuk konten kreatif dan hiburan, dengan banyak selebritas, musisi, dan merek besar yang bergabung dengan platform ini untuk terhubung dengan audiens mereka.</p><h4>Alasan TikTok Diminati Sebagai Sosial Media</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SooX63jlgoTEbK0Sv2Y2lg.jpeg" /></figure><p>Alasan-alasan kenapa TikTok diminati oleh pengguna sosial media antara lain :</p><p><strong>1.Konten singkat</strong></p><p>TikTok memungkinkan pengguna untuk membuat dan melihat video singkat dalam durasi 15 hingga 60 detik. Ini membuat konten di TikTok lebih mudah dicerna dan tidak membosankan.</p><p><strong>2.Fitur edit yang mudah dan lengkap</strong></p><p>TikTok dilengkapi dengan fitur editing yang lengkap dan mudah digunakan seperti filter, efek visual, musik, dan pencahayaan. Fitur-fitur ini membuat video menjadi lebih kreatif dan menarik.</p><p><strong>3.Konten yang mudah ditemukan</strong></p><p>TikTok memungkinkan pengguna untuk menemukan konten-konten baru dengan mudah. Selain itu, TikTok juga merekomendasikan video berdasarkan preferensi pengguna.</p><p><strong>4.Potensi viral</strong></p><p>TikTok memiliki potensi untuk membuat konten yang menjadi viral dalam waktu singkat. Hal ini memungkinkan merek tersebar luas dengan cepat dan efektif.</p><p><strong>5.Platform kreatif</strong></p><p>TikTok memungkinkan pengguna untuk mengekspresikan kreativitas mereka melalui video, musik, tarian, dan tantangan yang sedang populer.</p><h4>Fitur Tiktok</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/980/1*gDxtPBnQEXYDwjTBykXSlg.png" /></figure><p>Fitur-fitur yang mendukung TikTok antara lain :</p><p><strong>1.Fitur Music</strong></p><p>Fitur utama pada aplikasi Tik Tok yaitu musik, pengguna dapat menambahkan beragam jenis musik yang sesuai dengan konten video.</p><p><strong>2.Filter Video</strong></p><p>Pengguna bisa menambahkan filter pada video untuk menyesuaikan tone warna pada video., dan rona sesuai dengan objek video.</p><p><strong>3.Fitur Live</strong></p><p>Tik Tok juga memiliki fitur live yang dapat oleh digunakan oleh penggunanya yang memiliki minimal 1000 followers .</p><p><strong>4.Filter Voice Changer</strong></p><p>Pengguna dapat mengubah suaranya dengan mudah melalui fitur ini. Beragam efek suara yang berbeda dapat diterapkan ke dalam video.</p><p><strong>5.Filter Auto Captions</strong></p><p>Fitur ini memungkinkan kreator konten Tik Tok menyertakan subtitle yang dibuat secara otomatis oleh aplikasi.</p><h4>Statistik Jumlah Pengguna TikTok</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/850/1*XvJrWiHOphwX8ra9JtWKmA.png" /></figure><p>Diatas adalah grafik yang menunjukkan peningkatan jumlah pengguna TikTok per Kuartal II (2018–2022)</p><h4>Dampak Positif TikTok</h4><p>Dampak postif yang dihasilkan oleh TikTok sebagai sosial media antara lain :</p><p><strong>1.Update Berita</strong></p><p>Melalui Tiktok user dapat melihat berbagai macam berita ter-update yang disajikan melalui beragam video.</p><p><strong>2.Melatih Kepercayaan Diri</strong></p><p>Konten yang ditampilkan membuat semua orang ingin menampilkan hal terbaik untuk ditonton audiens yang luas.</p><p><strong>3.Menambah Teman dan Penghasilan</strong></p><p>Konten viral yang dihadirkan Tiktok sangat berdampak pada kehidupan sosial dan ekonomi</p><h4>Dampak Negatif TikTok</h4><p>Tidak hanya dampak positif yang dihasilkan TikTok, akan tetapi dampak negatif juga ikut mempengaruhi lingkungan sosial. berikut dampak negatif TikTok :</p><p><strong>1.Tidak Dibatasi Umur</strong></p><p>TikTok dapat diakses untuk segala usia sehingga konten yang kurang pantas juga dapat dilihat oleh anak-anak</p><p><strong>2.Menyia-nyiakan Waktu</strong></p><p>Para pengguna TikTok terkadang melalaikan waktu produktif mereka untuk belajar dan melakukan hal positif lainnya.</p><p><strong>3.Rentan Ujaran Kebencian</strong></p><p>TikTok ini sering disalahgunakan oleh para konten kreator untuk mencari ketenaran dengan saling menghujat.</p><h4>TikTok dalam membentuk komunitas dan meningkatkan kreativitas</h4><p><strong>#BookTok</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6iEkrLmJfnATT7e00EmWxw.png" /></figure><p>Gerakan ini dimulai oleh pengguna TikTok yang suka membaca dan mulai berbagi rekomendasi buku dan ulasan singkat melalui video di platform tersebut. Gerakan ini tumbuh dengan cepat dan membentuk sebuah komunitas pembaca yang saling mendukung dan berbagi rekomendasi buku.</p><h4>Dampak TikTok Terhadap Interaksi Sosial</h4><p>TikTok memberi dukungan fitur yang memungkinkan pengguna untuk berinteraksi satu sama lain dengan cara menonton, mengomentari, atau memberikan dukungan melalui like dan share pada video-video yang diunggah. Selain itu, dengan fitur yang mendukung pengguna untuk membuat konten dalam bentuk video singkat serta <em>editing tools </em>yang lengkap, pengguna dapat menciptakan konten yang unik dan membangun brand image mereka sendiri.</p><p>TikTok juga menjadi platform yang menyenangkan dan menghibur. Banyak pengguna menghabiskan waktu dengan menonton video pendek dan konten kreatif. Dengan populernya TikTok dan potensi viral dari sebuah video yang diunggah di dalam TikTok, Banyak pengguna yang memanfaatkan TikTok untuk membuat konten rekomendasi dan promosi mengenai produk atau barang yang mereka jual kepada pengguna lain. Hal itu melengkapi fungsi TikTok sebagai platform sosial media.</p><p>Akan tetapi, tidak hanya hal positif saja yang dipengaruhi oleh TikTok. TikTok juga berpotensi membuat anak muda menjadi lupa waktu dimana mereka akan membuang-buang waktu mereka menonton konten TikTok dari pada melakukan hal yang lebih positif. Kemudian dengan konten TikTok yang tidak dibatasi oleh umur, anak-anak dibawah umur berpotensi menonton konten yang tidak pantas untuk umur mereka. Hal itu tentunya akan merusak pemikiran generasi muda.</p><p><strong>Tonton Penjelasan lebih detail di youtube :</strong></p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2F2Z43hURldM0%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D2Z43hURldM0&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2F2Z43hURldM0%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/ef7f34031acdde679aa14f0db99956f7/href">https://medium.com/media/ef7f34031acdde679aa14f0db99956f7/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=edd85220716a" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>