Dasar Pemrograman Golang

website·Indexed 33 days ago

https://dasarpemrogramangolang.novalagung.com/

A comprehensive guide to Go programming focusing on web development and system integration. Topics include web frameworks like Echo, HTTP/2, gRPC with Protobuf, JWT, LDAP authentication, and secure middleware. It also covers file handling with Excelize, gofpdf, and etree, as well as network protocols including FTP, SSH, SFTP, and SMTP.

Tokens
104.1K
Snippets
563
Records
642
Agent score
58%

What's inside Dasar Pemrograman Golang

  1. Overview of Dasar Pemrograman Golang learning resources

    Dasar Pemrograman Golang is a comprehensive learning resource for the Go programming language, consisting of over 160 chapters divided into four progressive categories:

    1. Basic Go Programming: Covers installation, execution, keywords, pointers, structs, interfaces, reflect, goroutines, channels, and date time.
    2. Basic Go Web Programming: Focuses on web development fundamentals using only Go's internal APIs (routing, multiplexer, middleware, cookies).
    3. Advanced Go Programming: Covers advanced topics and popular community libraries, including HTTP, SSL, CORS, CSRF, mail, PDF, Excel, FTP, SSH, WebSockets, Protobuf, and gRPC.
    4. Case Studies: Provides Proof of Concept (PoC) for solving real-world project problems using Go.

    The resource is compatible with Go version 1.26.4.

  2. Introduction to Go Channels

    Channels are thread-safe communication mechanisms used to connect goroutines by transferring data between them. While goroutines execute asynchronously, the act of sending and receiving data via a channel is blocking (synchronous). This means the execution of the program will pause at a channel operation until the data transfer is complete.
  3. Use the empty interface (any) to handle dynamic types

    In Go, an empty interface is denoted by interface{} or the alias any. A variable of this type can hold any value regardless of its type (numeric, string, slice, pointer, etc.), enabling dynamic typing behavior. any is a type alias for interface{} and they are functionally identical.
    var secret any
    
    secret = "ethan hunt"
    secret = []string{"apple", "mango", "banana"}
    secret = 12.4
  4. Understand CORS fundamentals in Go web applications

    Cross-Origin Resource Sharing (CORS) is a browser-side security mechanism that determines whether a web application running at one origin (domain) can access resources from a different origin. CORS only affects requests made via JavaScript in a browser; requests made via tools like curl or from other back-end services are not subject to CORS rules. CORS configuration is implemented on the server side by manipulating specific response headers.
  5. Understand the Pipeline Concurrency Pattern in Go

    The Pipeline pattern consists of a series of concurrent processes (stages) that are logically connected. Each stage is typically implemented as a goroutine that performs a specific task and passes the result to the next stage via a channel. This approach improves performance by allowing different stages of a process to run in parallel for different data items, maximizing I/O and CPU efficiency. For example, while stage B is archiving the first file, stage A can simultaneously be dumping the second file.
  6. Understand JSON Web Token (JWT) Structure

    JWT is a JSON standard (RFC 7519) used for access tokens. A JWT consists of three parts encoded and cryptographically signed:

    1. Header: Specifies the algorithm used to generate the signature.
    2. Payload: Contains the data (known as Claims) used for authentication, such as user grants, groups, or login timestamps.
    3. Signature: A cryptographic hash of the encoded header, encoded payload, and a secret/private key.

    Unlike traditional token-based authorization where tokens are stored in a database, JWTs are validated by verifying the signature using a secret key known only to the server. The payload is encoded, not encrypted, meaning it can be read by anyone; however, it cannot be modified without invalidating the signature.

  7. Implement the Context Cancellation Pipeline pattern in Go

    The Context Cancellation pattern is used to forcibly terminate ongoing concurrent processes due to timeouts, errors, or other external factors. In Go, this is implemented using the context.Context API, which carries deadlines, cancellation signals, and request-scoped values across API boundaries and goroutines.
  8. Prevent duplicate concurrent function calls with singleflight

    The singleflight package is used to suppress duplicate function calls that occur simultaneously and produce the same output. This is particularly useful for expensive operations like generating reports or fetching data from a database where multiple users might request the same resource at the same time. Instead of executing the operation multiple times, singleflight ensures the operation is performed only once, and all concurrent callers wait for and receive the same result.
  9. Understand Goroutine basics and resource usage

    A Goroutine is a lightweight execution unit, often described as a 'mini thread'. They are asynchronous and significantly more efficient than native threads, requiring only about 2kB of memory to start. While Go can handle a vast number of goroutines, developers should consider the complexity of the logic within the goroutine, as it impacts hardware resource consumption beyond just the initial memory footprint.
  10. Understand LDAP and Directory Services basics

    LDAP (Lightweight Directory Access Protocol) is a client-server protocol used to access Directory Services. Directory Services manage and provide access to network resources such as emails, computers, files, and printers. A key operation in LDAP is the 'Bind Operation', which is used to authenticate a client to the directory server and change the client's authorization state by sending a Bind DN and password.