Pelajari Dasar-Dasar Golang | MRFDN.COM
mrfdn.com – Dalam postingan ini saya ingin mendokumentasikan bagaimana saya menjalankan proyek Go/Golang pertama saya.
Go dapat digunakan untuk membuat aplikasi web, mulai dari rest apis, hingga aplikasi web yang kompleks.
Untuk memulai, mari belajar menulis kode Go pertama kita.
Pastikan go terinstal di komputer Anda.
Pertamamembuat direktori proyek
mkdir mygoproject
cd mygoproject
Jalankan program go#
Di dalamnya kita memulai program dengan perintah:
Anda akan segera melihat file baru bernama go.mod
Terjadi seperti ini:
module mygoproject
go 1.22.2
File go.mod ini akan digunakan untuk memelihara konfigurasi tentang paket-paket yang diperlukan. File ini cukup untuk menyimpan proyek kecil. Jika proyeknya besar, maka kami akan meletakkan modul di tempat yang tepat.
Buat direktori main.go untuk menjalankan server web#
Kemudian buat file bernama main.go
Lalu isikan seperti ini:
package main
import (
"fmt"
"net/http"
)
func main() {
fmt.Println("halo terminal")
mux := http.NewServeMux()
mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
fmt.Fprint(w, "hai browser")
})
http.ListenAndServe("localhost:8081", mux)
}
File proyek mulai#
Jadi programnya terlihat seperti ini:
.
├── go.mod
└── main.go
Menjalankan program ayo#
Sekarang buka terminal lalu klik,
Di dalam kotak Anda akan melihat kata-katanya halo terminaldan jika mengakses browser web dengan alamatnya localhost:8081 kamu bisa melihat tulisannya halo browser.
Terapkan ke program go#
Anda dapat mengkompilasi executable tersebut sehingga menjadi file biner yang dapat langsung dieksekusi dan dijalankan.
Cara menginstal program:
File biner akan memiliki nama yang sama dengan file program.
Jika Anda ingin menetapkan nama file biner tertentu, gunakan perintah
Oleh karena itu nama file biner app.
Itulah tutorial singkat cara membuat, menjalankan dan membangun/mengkompilasi go/golang.
Semoga bermanfaat.
PakarPBN
A Private Blog Network (PBN) is a collection of websites that are controlled by a single individual or organization and used primarily to build backlinks to a “money site” in order to influence its ranking in search engines such as Google. The core idea behind a PBN is based on the importance of backlinks in Google’s ranking algorithm. Since Google views backlinks as signals of authority and trust, some website owners attempt to artificially create these signals through a controlled network of sites.
In a typical PBN setup, the owner acquires expired or aged domains that already have existing authority, backlinks, and history. These domains are rebuilt with new content and hosted separately, often using different IP addresses, hosting providers, themes, and ownership details to make them appear unrelated. Within the content published on these sites, links are strategically placed that point to the main website the owner wants to rank higher. By doing this, the owner attempts to pass link equity (also known as “link juice”) from the PBN sites to the target website.
The purpose of a PBN is to give the impression that the target website is naturally earning links from multiple independent sources. If done effectively, this can temporarily improve keyword rankings, increase organic visibility, and drive more traffic from search results.