This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "fmt" | |
func main() { | |
// Membuat map dengan make | |
a := make(map[string]int) | |
a["apple"] = 10 | |
a["banana"] = 5 | |
fmt.Println(a) // Output: map[apple:10 banana:5] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "fmt" | |
func main() { | |
// Membuat slice dengan make | |
a := make([]int, 5) | |
fmt.Println(a) // Output: [0 0 0 0 0] | |
// Membuat slice dengan sintaks []T |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "fmt" | |
// Kelas Mahasiswa dengan atribut nama dan jurusan | |
type Mahasiswa struct { | |
nama string | |
jurusan string | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPDX-License-Identifier: GPL-3.0 | |
pragma solidity >=0.4.22 <0.9.0; | |
library TestsAccounts { | |
function getAccount(uint index) pure public returns (address) { | |
address[15] memory accounts; | |
accounts[0] = 0x5B38Da6a701c568545dCfcB03FcB875f56beddC4; | |
accounts[1] = 0xAb8483F64d9C6d1EcF9b849Ae677dD3315835cb2; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package book | |
import "gorm.io/gorm" | |
type Repository interface { | |
FindAll() ([]Book, error) | |
FindByID(ID int) (Book, error) | |
Create(book Book) (Book, error) | |
Update(book Book) (Book, error) | |
Delete(book Book) (Book, error) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"github.com/gin-gonic/gin" | |
) | |
func main() { | |
router := gin.Default() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func rootHandler(c *gin.Context) { | |
c.JSON(200, gin.H{ | |
"Name": "sakura endo", | |
"Age": 20, | |
"Address": "Tokyo", | |
}) | |
} | |
func helloHandler(c *gin.Context) { | |
c.JSON(200, gin.H{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"github.com/gin-gonic/gin" | |
) | |
func main() { | |
router := gin.Default() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"errors" | |
"fmt" | |
"strings" | |
) | |
func validate(input string) (bool, error) { | |
if strings.TrimSpace(input) == "" { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"errors" | |
"fmt" | |
"strconv" | |
"strings" | |
) | |
func validate(input string) (bool, error) { |