{"id":33654,"date":"2025-11-05T14:40:53","date_gmt":"2025-11-05T11:40:53","guid":{"rendered":"https:\/\/fatihsoysal.com\/blog\/?p=33654"},"modified":"2025-11-05T14:40:53","modified_gmt":"2025-11-05T11:40:53","slug":"goda-paket-yazimi-kapsamli-bir-rehber","status":"publish","type":"post","link":"https:\/\/fatihsoysal.com\/blog\/goda-paket-yazimi-kapsamli-bir-rehber\/","title":{"rendered":"Go&#8217;da Paket Yaz\u0131m\u0131: Kapsaml\u0131 Bir Rehber"},"content":{"rendered":"<p><body><\/p>\n<h2>Go&#8217;da Paket Yaz\u0131m\u0131: Kapsaml\u0131 Bir Rehber<\/h2>\n<p>Go programlama dili, mod\u00fclerlik, yeniden kullan\u0131labilirlik ve kod organizasyonu konular\u0131nda paketlere b\u00fcy\u00fck \u00f6nem verir. Paketler, Go projelerinin temel yap\u0131 ta\u015flar\u0131d\u0131r ve b\u00fcy\u00fck \u00f6l\u00e7ekli uygulamalar\u0131n geli\u015ftirilmesini kolayla\u015ft\u0131ran, bak\u0131m\u0131 yap\u0131labilir ve anla\u015f\u0131l\u0131r kod tabanlar\u0131 olu\u015fturmaya olanak tan\u0131r. Bu makalede, Go&#8217;da paketlerin ne oldu\u011funu, nas\u0131l olu\u015fturuldu\u011funu, y\u00f6netildi\u011fini ve en iyi uygulamalarla nas\u0131l tasarlanmas\u0131 gerekti\u011fini derinlemesine inceleyece\u011fiz.<\/p>\n<h3>Giri\u015f: Go Paketleri Neden \u00d6nemlidir?<\/h3>\n<p>Go&#8217;da her program, bir paketin par\u00e7as\u0131d\u0131r. K\u00fc\u00e7\u00fck bir &#8220;Merhaba D\u00fcnya&#8221; uygulamas\u0131 bile <code>package main<\/code> ad\u0131nda bir paketin i\u00e7inde yer al\u0131r. Paketler, ilgili fonksiyonlar\u0131, tipleri, de\u011fi\u015fkenleri ve sabitleri bir araya getirerek kodun mant\u0131ksal birimlere ayr\u0131lmas\u0131n\u0131 sa\u011flar. Bu ayr\u0131m, a\u015fa\u011f\u0131daki avantajlar\u0131 sunar:<\/p>\n<p>*   <strong>Mod\u00fclerlik:<\/strong> Kodu k\u00fc\u00e7\u00fck, y\u00f6netilebilir par\u00e7alara ay\u0131r\u0131r, bu da her bir par\u00e7an\u0131n ayr\u0131 ayr\u0131 geli\u015ftirilmesini ve test edilmesini kolayla\u015ft\u0131r\u0131r.<br \/>\n*   <strong>Yeniden Kullan\u0131labilirlik:<\/strong> Bir pakette tan\u0131mlanan i\u015flevler, farkl\u0131 projelerde veya ayn\u0131 projenin farkl\u0131 yerlerinde kolayca kullan\u0131labilir. Bu, kod tekrar\u0131n\u0131 azalt\u0131r ve geli\u015ftirme s\u00fcrecini h\u0131zland\u0131r\u0131r.<br \/>\n*   <strong>Organizasyon:<\/strong> B\u00fcy\u00fck projelerde kodun d\u00fczenli ve anla\u015f\u0131l\u0131r kalmas\u0131n\u0131 sa\u011flar. Belirli bir i\u015flevselli\u011fi ararken, ilgili pakete do\u011frudan bak\u0131labilir.<br \/>\n*   <strong>\u0130sim \u00c7ak\u0131\u015fmalar\u0131n\u0131 \u00d6nleme:<\/strong> Her paketin kendi isim alan\u0131 vard\u0131r, bu da farkl\u0131 paketlerde ayn\u0131 isimde fonksiyon veya de\u011fi\u015fkenlerin bulunmas\u0131na izin verirken \u00e7ak\u0131\u015fmalar\u0131 \u00f6nler.<\/p>\n<p>Go&#8217;nun standart k\u00fct\u00fcphanesi de asl\u0131nda bir dizi paketten olu\u015fur (\u00f6rn. <code>fmt<\/code>, <code>net\/http<\/code>, <code>io<\/code>). Bu, Go ekosisteminin pakete dayal\u0131 bir felsefeye sahip oldu\u011funun en a\u00e7\u0131k g\u00f6stergesidir.<\/p>\n<h3>Temel Paket Kavramlar\u0131<\/h3>\n<p>Go&#8217;da paketlerle \u00e7al\u0131\u015fmaya ba\u015flamadan \u00f6nce baz\u0131 temel kavramlar\u0131 anlamak \u00f6nemlidir.<\/p>\n<h4><code>package main<\/code> ve Adland\u0131r\u0131lm\u0131\u015f Paketler<\/h4>\n<p>Her Go uygulamas\u0131 bir giri\u015f noktas\u0131na ihtiya\u00e7 duyar ve bu giri\u015f noktas\u0131 her zaman <code>package main<\/code> i\u00e7inde tan\u0131mlanan <code>main<\/code> fonksiyonudur. <code>package main<\/code>, \u00e7al\u0131\u015ft\u0131r\u0131labilir bir uygulama olu\u015fturmak i\u00e7in kullan\u0131lan \u00f6zel bir pakettir. Di\u011fer t\u00fcm paketler ise genellikle bir k\u00fct\u00fcphane veya yard\u0131mc\u0131 i\u015flevler k\u00fcmesi sa\u011flamak \u00fczere adland\u0131r\u0131lm\u0131\u015f paketlerdir (\u00f6rn. <code>package utils<\/code>, <code>package models<\/code>, <code>package http<\/code>).<\/p>\n<p>*   <strong><code>package main<\/code>:<\/strong> Uygulaman\u0131n \u00e7al\u0131\u015ft\u0131r\u0131labilir giri\u015f noktas\u0131d\u0131r. <code>go build<\/code> komutuyla bir y\u00fcr\u00fct\u00fclebilir dosya olu\u015fturulur.<br \/>\n*   <strong>Adland\u0131r\u0131lm\u0131\u015f Paketler:<\/strong> K\u00fct\u00fcphane olarak kullan\u0131lan ve di\u011fer paketler taraf\u0131ndan i\u00e7e aktar\u0131lan paketlerdir. <code>go build<\/code> ile do\u011frudan y\u00fcr\u00fct\u00fclemezler, ancak <code>go install<\/code> ile derlenip <code>GOPATH\/bin<\/code> veya <code>GOBIN<\/code> konumuna yerle\u015ftirilebilirler.<\/p>\n<h4><code>import<\/code> \u0130fadesi<\/h4>\n<p>Bir pakette tan\u0131mlanan i\u015flevleri veya tipleri ba\u015fka bir pakette kullanmak i\u00e7in <code>import<\/code> ifadesi kullan\u0131l\u0131r. <code>import<\/code> ifadesi, paketin tam yolunu belirtir.<\/p>\n<pre><code class=\"language-go\">package main\n\nimport (\n    \"fmt\" \/\/ Standart k\u00fct\u00fcphane paketi\n    \"math\" \/\/ Standart k\u00fct\u00fcphane paketi\n    \"myproject\/utils\" \/\/ Kendi yazd\u0131\u011f\u0131m\u0131z bir paket\n)\n\nfunc main() {\n    fmt.Println(\"Merhaba Go!\")\n    fmt.Println(\"Pi say\u0131s\u0131:\", math.Pi)\n    fmt.Println(\"Toplam:\", utils.Add(5, 3))\n}<\/code><\/pre>\n<p>Yukar\u0131daki \u00f6rnekte, <code>fmt<\/code> ve <code>math<\/code> standart k\u00fct\u00fcphane paketleridir. <code>myproject\/utils<\/code> ise bizim projemizin i\u00e7inde yer alan \u00f6zel bir pakettir.<\/p>\n<h4>G\u00f6r\u00fcn\u00fcrl\u00fck (Visibility) Kurallar\u0131<\/h4>\n<p>Go&#8217;da bir eleman\u0131n (fonksiyon, de\u011fi\u015fken, tip, sabit) ba\u015fka paketlerden eri\u015filebilir olup olmad\u0131\u011f\u0131n\u0131 belirleyen basit bir kural vard\u0131r:<\/p>\n<p>*   <strong>D\u0131\u015fa Aktar\u0131lm\u0131\u015f (Exported):<\/strong> E\u011fer bir eleman\u0131n ismi b\u00fcy\u00fck harfle ba\u015fl\u0131yorsa (\u00f6rn. <code>MyFunction<\/code>, <code>MyType<\/code>, <code>MyVariable<\/code>), o eleman paket d\u0131\u015f\u0131ndan eri\u015filebilir (d\u0131\u015fa aktar\u0131lm\u0131\u015ft\u0131r).<br \/>\n*   <strong>D\u0131\u015fa Aktar\u0131lmam\u0131\u015f (Unexported):<\/strong> E\u011fer bir eleman\u0131n ismi k\u00fc\u00e7\u00fck harfle ba\u015fl\u0131yorsa (\u00f6rn. <code>myFunction<\/code>, <code>myType<\/code>, <code>myVariable<\/code>), o eleman yaln\u0131zca tan\u0131mland\u0131\u011f\u0131 paket i\u00e7inde eri\u015filebilir (d\u0131\u015fa aktar\u0131lmam\u0131\u015ft\u0131r).<\/p>\n<p>Bu kural, paketlerin dahili implementasyon detaylar\u0131n\u0131 d\u0131\u015far\u0131ya s\u0131zd\u0131rmadan temiz API&#8217;ler sunmas\u0131n\u0131 sa\u011flar.<\/p>\n<pre><code class=\"language-go\">\/\/ utils\/math.go\npackage utils\n\n\/\/ Add iki say\u0131y\u0131 toplar ve sonucu d\u00f6nd\u00fcr\u00fcr. (D\u0131\u015fa aktar\u0131lm\u0131\u015f)\nfunc Add(a, b int) int {\n    return a + b\n}\n\n\/\/ subtract iki say\u0131y\u0131 \u00e7\u0131kar\u0131r ve sonucu d\u00f6nd\u00fcr\u00fcr. (D\u0131\u015fa aktar\u0131lmam\u0131\u015f)\nfunc subtract(a, b int) int {\n    return a - b\n}<\/code><\/pre>\n<pre><code class=\"language-go\">\/\/ main.go\npackage main\n\nimport (\n    \"fmt\"\n    \"myproject\/utils\"\n)\n\nfunc main() {\n    fmt.Println(utils.Add(10, 5)) \/\/ \u00c7al\u0131\u015f\u0131r, \u00e7\u00fcnk\u00fc Add d\u0131\u015fa aktar\u0131lm\u0131\u015ft\u0131r.\n    \/\/ fmt.Println(utils.subtract(10, 5)) \/\/ Hata verir, \u00e7\u00fcnk\u00fc subtract d\u0131\u015fa aktar\u0131lmam\u0131\u015ft\u0131r.\n}<\/code><\/pre>\n<h4>Paket \u0130simleri ve Dizin \u0130simleri<\/h4>\n<p>Genellikle bir paketin ismi, i\u00e7inde bulundu\u011fu dizinin ismiyle ayn\u0131 olmal\u0131d\u0131r. Bu bir zorunluluk de\u011fil, bir kurald\u0131r ve Go toplulu\u011funda yayg\u0131n olarak kabul g\u00f6rm\u00fc\u015ft\u00fcr. \u00d6rne\u011fin, <code>utils<\/code> adl\u0131 bir dizin i\u00e7indeki Go dosyalar\u0131 <code>package utils<\/code> olarak ba\u015flamal\u0131d\u0131r. Ancak, ayn\u0131 dizin i\u00e7indeki t\u00fcm Go dosyalar\u0131 ayn\u0131 <code>package<\/code> bildirimiyle ba\u015flamal\u0131d\u0131r. Bir dizin i\u00e7inde birden fazla paket olamaz.<\/p>\n<h3>Paket Yap\u0131s\u0131<\/h3>\n<p>Go projeleri genellikle belirli bir dizin yap\u0131s\u0131n\u0131 takip eder. Go Mod\u00fclleri ile bu yap\u0131 daha esnek hale gelmi\u015ftir, ancak temel prensipler ayn\u0131d\u0131r.<\/p>\n<h4>Go Mod\u00fclleri ve Proje Yap\u0131s\u0131<\/h4>\n<p>Modern Go projeleri Go Mod\u00fclleri kullan\u0131r. Bir Go mod\u00fcl\u00fc, bir veya daha fazla paketin koleksiyonudur ve ba\u011f\u0131ml\u0131l\u0131k y\u00f6netimini sa\u011flar.<\/p>\n<p>1.  <strong>Mod\u00fcl Ba\u015flatma:<\/strong> Projenizin k\u00f6k dizininde <code>go mod init <modul_yolu><\/code> komutuyla bir mod\u00fcl ba\u015flat\u0131l\u0131r. <code><modul_yolu><\/code> genellikle projenizin VCS (\u00f6rn. GitHub) yoluyla ayn\u0131d\u0131r, \u00f6rne\u011fin <code>github.com\/kullaniciadi\/projeadi<\/code>. Bu, <code>go.mod<\/code> dosyas\u0131n\u0131 olu\u015fturur.<br \/>\n2.  <strong>Paket Dizinleri:<\/strong> Her paket, mod\u00fcl k\u00f6k dizini alt\u0131nda kendi dizininde yer al\u0131r.<\/p>\n<pre><code class=\"language-\">myproject\/\n\u251c\u2500\u2500 go.mod\n\u251c\u2500\u2500 main.go\n\u251c\u2500\u2500 utils\/\n\u2502   \u2514\u2500\u2500 math.go\n\u251c\u2500\u2500 models\/\n\u2502   \u2514\u2500\u2500 user.go\n\u2514\u2500\u2500 config\/\n    \u2514\u2500\u2500 settings.go<\/code><\/pre>\n<p>Bu yap\u0131da:<br \/>\n*   <code>myproject<\/code> mod\u00fcl\u00fcn\u00fcn k\u00f6k dizinidir.<br \/>\n*   <code>main.go<\/code>, <code>package main<\/code> i\u00e7indedir.<br \/>\n*   <code>utils\/math.go<\/code>, <code>package utils<\/code> i\u00e7indedir.<br \/>\n*   <code>models\/user.go<\/code>, <code>package models<\/code> i\u00e7indedir.<br \/>\n*   <code>config\/settings.go<\/code>, <code>package config<\/code> i\u00e7indedir.<\/p>\n<p>Di\u011fer paketlerden bu paketleri i\u00e7e aktar\u0131rken, mod\u00fcl yolu kullan\u0131l\u0131r:<br \/>\n<code>import \"github.com\/kullaniciadi\/projeadi\/utils\"<\/code><\/p>\n<h4>Alt Paketler<\/h4>\n<p>Bir paket, mant\u0131ksal olarak daha k\u00fc\u00e7\u00fck birimlere ayr\u0131labilecek kadar b\u00fcy\u00fcd\u00fc\u011f\u00fcnde, alt paketler olu\u015fturulabilir. \u00d6rne\u011fin, bir <code>http<\/code> paketi alt\u0131nda <code>server<\/code>, <code>client<\/code>, <code>middleware<\/code> gibi alt paketler olabilir.<\/p>\n<pre><code class=\"language-\">myproject\/\n\u251c\u2500\u2500 go.mod\n\u251c\u2500\u2500 main.go\n\u251c\u2500\u2500 http\/\n\u2502   \u251c\u2500\u2500 server\/\n\u2502   \u2502   \u2514\u2500\u2500 server.go \/\/ package server\n\u2502   \u251c\u2500\u2500 client\/\n\u2502   \u2502   \u2514\u2500\u2500 client.go \/\/ package client\n\u2502   \u2514\u2500\u2500 handlers.go   \/\/ package http (handlerlar do\u011frudan http paketi i\u00e7inde olabilir)<\/code><\/pre>\n<p>Bu durumda, <code>server.go<\/code> dosyas\u0131 <code>package server<\/code> olarak ba\u015flar ve <code>http<\/code> paketi i\u00e7inden <code>http\/server<\/code> olarak i\u00e7e aktar\u0131l\u0131r. <code>handlers.go<\/code> ise <code>package http<\/code> olarak kal\u0131r.<\/p>\n<h3>Paket Olu\u015fturma Ad\u0131mlar\u0131<\/h3>\n<p>\u015eimdi pratik bir \u00f6rnek \u00fczerinden kendi Go paketinizi nas\u0131l olu\u015fturaca\u011f\u0131n\u0131z\u0131 g\u00f6relim. Basit bir matematik i\u015flemleri paketi olu\u015ftural\u0131m.<\/p>\n<p>1.  <strong>Yeni Bir Mod\u00fcl Ba\u015flat\u0131n:<\/strong><br \/>\n    \u00d6ncelikle, projeniz i\u00e7in bir dizin olu\u015fturun ve i\u00e7ine girin:<\/p>\n<pre><code class=\"language-bash\">mkdir mymathlib\n    cd mymathlib\n    go mod init example.com\/mymathlib<\/code><\/pre>\n<p>    Bu komut, <code>go.mod<\/code> dosyas\u0131n\u0131 olu\u015fturacakt\u0131r.<\/p>\n<p>2.  <strong>Paket Dizini Olu\u015fturun:<\/strong><br \/>\n    <code>mymathlib<\/code> mod\u00fcl\u00fc i\u00e7inde <code>calculator<\/code> ad\u0131nda bir paket olu\u015fturmak i\u00e7in bir dizin olu\u015fturun:<\/p>\n<pre><code class=\"language-bash\">mkdir calculator<\/code><\/pre>\n<p>3.  <strong>Paket Dosyas\u0131n\u0131 Yaz\u0131n:<\/strong><br \/>\n    <code>calculator<\/code> dizini i\u00e7inde <code>calculator.go<\/code> ad\u0131nda bir dosya olu\u015fturun ve i\u00e7ine a\u015fa\u011f\u0131daki kodu yaz\u0131n:<\/p>\n<pre><code class=\"language-go\">\/\/ calculator\/calculator.go\n    package calculator\n\n    \/\/ Add fonksiyonu iki tam say\u0131y\u0131 toplar ve sonucu d\u00f6nd\u00fcr\u00fcr.\n    func Add(a, b int) int {\n        return a + b\n    }\n\n    \/\/ Subtract fonksiyonu iki tam say\u0131dan birincisinden ikincisini \u00e7\u0131kar\u0131r.\n    func Subtract(a, b int) int {\n        return a - b\n    }\n\n    \/\/ Multiply fonksiyonu iki tam say\u0131y\u0131 \u00e7arpar.\n    func Multiply(a, b int) int {\n        return a * b\n    }\n\n    \/\/ Divide fonksiyonu iki tam say\u0131y\u0131 b\u00f6ler ve sonucu d\u00f6nd\u00fcr\u00fcr.\n    \/\/ S\u0131f\u0131ra b\u00f6lme durumunda bir hata d\u00f6nd\u00fcr\u00fcr.\n    func Divide(a, b int) (int, error) {\n        if b == 0 {\n            return 0, fmt.Errorf(\"s\u0131f\u0131ra b\u00f6lme hatas\u0131\") \/\/ fmt paketi import edilmeli\n        }\n        return a \/ b, nil\n    }<\/code><\/pre>\n<p>    <em>Not: Yukar\u0131daki <code>Divide<\/code> fonksiyonunda <code>fmt<\/code> paketi kullan\u0131ld\u0131\u011f\u0131 i\u00e7in dosyan\u0131n ba\u015f\u0131na <code>import \"fmt\"<\/code> eklemeyi unutmay\u0131n.<\/em><\/p>\n<p>4.  <strong>Paketi Kullan\u0131n:<\/strong><br \/>\n    \u015eimdi, <code>mymathlib<\/code> mod\u00fcl\u00fcn\u00fcn k\u00f6k dizininde (yani <code>calculator<\/code> dizininin bir \u00fcst\u00fcnde) <code>main.go<\/code> ad\u0131nda bir dosya olu\u015fturun ve <code>calculator<\/code> paketini kullan\u0131n:<\/p>\n<pre><code class=\"language-go\">\/\/ main.go\n    package main\n\n    import (\n        \"fmt\"\n        \"example.com\/mymathlib\/calculator\" \/\/ Kendi paketimizi import ediyoruz\n    )\n\n    func main() {\n        sum := calculator.Add(10, 5)\n        fmt.Printf(\"10 + 5 = %d\\n\", sum)\n\n        diff := calculator.Subtract(10, 5)\n        fmt.Printf(\"10 - 5 = %d\\n\", diff)\n\n        product := calculator.Multiply(10, 5)\n        fmt.Printf(\"10 * 5 = %d\\n\", product)\n\n        quotient, err := calculator.Divide(10, 2)\n        if err != nil {\n            fmt.Printf(\"B\u00f6lme hatas\u0131: %s\\n\", err)\n        } else {\n            fmt.Printf(\"10 \/ 2 = %d\\n\", quotient)\n        }\n\n        quotientZero, errZero := calculator.Divide(10, 0)\n        if errZero != nil {\n            fmt.Printf(\"B\u00f6lme hatas\u0131: %s\\n\", errZero)\n        } else {\n            fmt.Printf(\"10 \/ 0 = %d\\n\", quotientZero)\n        }\n    }<\/code><\/pre>\n<p>5.  <strong>Uygulamay\u0131 \u00c7al\u0131\u015ft\u0131r\u0131n:<\/strong><br \/>\n    <code>mymathlib<\/code> mod\u00fcl\u00fcn\u00fcn k\u00f6k dizininde <code>go run main.go<\/code> komutunu \u00e7al\u0131\u015ft\u0131r\u0131n:<\/p>\n<pre><code class=\"language-bash\">go run main.go<\/code><\/pre>\n<p>    \u00c7\u0131kt\u0131 \u015f\u00f6yle olacakt\u0131r:<\/p>\n<pre><code class=\"language-\">10 + 5 = 15\n    10 - 5 = 5\n    10 * 5 = 50\n    10 \/ 2 = 5\n    B\u00f6lme hatas\u0131: s\u0131f\u0131ra b\u00f6lme hatas\u0131<\/code><\/pre>\n<p>Bu basit \u00f6rnek, kendi Go paketinizin nas\u0131l olu\u015fturulaca\u011f\u0131n\u0131, d\u0131\u015fa aktar\u0131lan i\u015flevleri nas\u0131l tan\u0131mlayaca\u011f\u0131n\u0131z\u0131 ve bunlar\u0131 ba\u015fka bir pakette nas\u0131l kullanaca\u011f\u0131n\u0131z\u0131 g\u00f6stermektedir.<\/p>\n<h3>Paketleri Kullanma<\/h3>\n<p>Paketleri kullan\u0131rken farkl\u0131 senaryolarla kar\u015f\u0131la\u015fabiliriz.<\/p>\n<h4>Yerel Paketleri \u0130\u00e7e Aktarma<\/h4>\n<p>Yukar\u0131daki \u00f6rnekte oldu\u011fu gibi, ayn\u0131 mod\u00fcl i\u00e7indeki paketleri i\u00e7e aktar\u0131rken, <code>go.mod<\/code> dosyas\u0131nda tan\u0131mlanan mod\u00fcl yolunu ve paketin g\u00f6receli yolunu kullan\u0131r\u0131z:<br \/>\n<code>import \"example.com\/mymathlib\/calculator\"<\/code><\/p>\n<h4>Standart K\u00fct\u00fcphane Paketlerini \u0130\u00e7e Aktarma<\/h4>\n<p>Go&#8217;nun zengin standart k\u00fct\u00fcphanesindeki paketler do\u011frudan isimleriyle i\u00e7e aktar\u0131l\u0131r:<br \/>\n<code>import \"fmt\"<\/code><br \/>\n<code>import \"net\/http\"<\/code><br \/>\n<code>import \"os\"<\/code><\/p>\n<h4>\u00dc\u00e7\u00fcnc\u00fc Taraf Paketleri \u0130\u00e7e Aktarma<\/h4>\n<p>Harici (\u00fc\u00e7\u00fcnc\u00fc taraf) paketleri kullanmak i\u00e7in <code>go get<\/code> komutunu kullan\u0131r\u0131z. Bu komut paketi indirir ve <code>go.mod<\/code> dosyan\u0131za ba\u011f\u0131ml\u0131l\u0131k olarak ekler.<\/p>\n<pre><code class=\"language-bash\">go get github.com\/gin-gonic\/gin<\/code><\/pre>\n<p>Ard\u0131ndan, bu paketi kodunuzda kullanabilirsiniz:<br \/>\n<code>import \"github.com\/gin-gonic\/gin\"<\/code><\/p>\n<h4>Paket Takma Adlar\u0131 (Aliases)<\/h4>\n<p>Bazen iki farkl\u0131 paketin ayn\u0131 isme sahip olmas\u0131 veya uzun bir paket ismini k\u0131saltmak istememiz gibi durumlar olabilir. Bu durumda paket takma adlar\u0131 (aliases) kullan\u0131r\u0131z:<\/p>\n<pre><code class=\"language-go\">import (\n    mycalc \"example.com\/mymathlib\/calculator\" \/\/ calculator paketine mycalc takma ad\u0131n\u0131 verdik\n    \"fmt\"\n)\n\nfunc main() {\n    sum := mycalc.Add(20, 10)\n    fmt.Printf(\"20 + 10 = %d\\n\", sum)\n}<\/code><\/pre>\n<h4>Bo\u015f \u0130\u00e7e Aktarma (Blank Import <code>_<\/code>)<\/h4>\n<p>Bazen bir paketi do\u011frudan kullanmak istemeyiz, ancak paketin <code>init<\/code> fonksiyonunun \u00e7al\u0131\u015fmas\u0131n\u0131 isteriz (genellikle veritaban\u0131 s\u00fcr\u00fcc\u00fcleri gibi yan etkileri olan paketler i\u00e7in). Bu durumda bo\u015f i\u00e7e aktarma kullan\u0131l\u0131r:<\/p>\n<pre><code class=\"language-go\">import _ \"github.com\/go-sql-driver\/mysql\" \/\/ Sadece init fonksiyonunu \u00e7al\u0131\u015ft\u0131r\u0131r<\/code><\/pre>\n<p>Bu, paketin d\u0131\u015fa aktar\u0131lan elemanlar\u0131n\u0131 kodunuzda kullanman\u0131za izin vermez, ancak paketin ba\u015flatma i\u015flemlerini tetikler.<\/p>\n<h4>Nokta \u0130\u00e7e Aktarma (Dot Import <code>.<\/code> &#8211; Dikkatli Kullan\u0131n)<\/h4>\n<p>Nokta i\u00e7e aktarma, paketin d\u0131\u015fa aktar\u0131lan t\u00fcm elemanlar\u0131n\u0131 mevcut paketin isim alan\u0131na getirir, b\u00f6ylece paket ismini belirtmeye gerek kalmaz.<\/p>\n<pre><code class=\"language-go\">import (\n    . \"fmt\" \/\/ fmt paketini nokta ile i\u00e7e aktard\u0131k\n)\n\nfunc main() {\n    Println(\"Merhaba, paket ismi olmadan!\") \/\/ fmt.Println yerine do\u011frudan Println kullan\u0131ld\u0131\n}<\/code><\/pre>\n<p>Bu, kodun daha k\u0131sa g\u00f6r\u00fcnmesini sa\u011flasa da, isim \u00e7ak\u0131\u015fmalar\u0131na yol a\u00e7abilece\u011fi ve kodun okunabilirli\u011fini azaltabilece\u011fi i\u00e7in genellikle tavsiye edilmez. Sadece test kodlar\u0131nda veya \u00e7ok \u00f6zel durumlarda kullan\u0131lmal\u0131d\u0131r.<\/p>\n<h3>Paket Y\u00f6netimi ve Mod\u00fcller<\/h3>\n<p>Go Mod\u00fclleri, Go 1.11 ile tan\u0131t\u0131lan ve Go projelerinde ba\u011f\u0131ml\u0131l\u0131k y\u00f6netimini k\u00f6kten de\u011fi\u015ftiren bir \u00f6zelliktir.<\/p>\n<h4><code>go.mod<\/code> ve <code>go.sum<\/code> Dosyalar\u0131<\/h4>\n<p>*   <strong><code>go.mod<\/code>:<\/strong> Bir mod\u00fcl\u00fcn k\u00f6k dizininde bulunur ve mod\u00fcl\u00fcn yolunu, Go s\u00fcr\u00fcm\u00fcn\u00fc ve t\u00fcm do\u011frudan ve dolayl\u0131 ba\u011f\u0131ml\u0131l\u0131klar\u0131n\u0131 (mod\u00fcl yollar\u0131 ve s\u00fcr\u00fcmleriyle birlikte) listeler.<br \/>\n*   <strong><code>go.sum<\/code>:<\/strong> Her ba\u011f\u0131ml\u0131l\u0131\u011f\u0131n kriptografik hash&#8217;lerini i\u00e7erir. Bu, indirilen ba\u011f\u0131ml\u0131l\u0131klar\u0131n de\u011fi\u015ftirilmedi\u011finden ve g\u00fcvenli oldu\u011fundan emin olmak i\u00e7in kullan\u0131l\u0131r.<\/p>\n<h4>Ba\u011f\u0131ml\u0131l\u0131k Ekleme, Y\u00fckseltme ve Kald\u0131rma<\/h4>\n<p>*   <strong>Ekleme:<\/strong> Bir paketi kodunuzda <code>import<\/code> etti\u011finizde ve <code>go build<\/code> veya <code>go run<\/code> gibi bir komut \u00e7al\u0131\u015ft\u0131rd\u0131\u011f\u0131n\u0131zda, Go otomatik olarak paketi indirir ve <code>go.mod<\/code> dosyas\u0131na ekler. Manuel olarak eklemek i\u00e7in <code>go get <paket_yolu><\/code> kullanabilirsiniz.<br \/>\n*   <strong>Y\u00fckseltme:<\/strong> Bir ba\u011f\u0131ml\u0131l\u0131\u011f\u0131n yeni bir s\u00fcr\u00fcm\u00fcne ge\u00e7mek i\u00e7in <code>go get -u <paket_yolu><\/code> veya <code>go get <paket_yolu>@latest<\/code> kullanabilirsiniz.<br \/>\n*   <strong>Kald\u0131rma:<\/strong> Kodunuzdan bir paketin t\u00fcm kullan\u0131mlar\u0131n\u0131 kald\u0131rd\u0131\u011f\u0131n\u0131zda, <code>go tidy<\/code> komutunu \u00e7al\u0131\u015ft\u0131rarak <code>go.mod<\/code> dosyas\u0131ndan gereksiz ba\u011f\u0131ml\u0131l\u0131klar\u0131 temizleyebilirsiniz.<\/p>\n<p><code>go mod tidy<\/code> komutu, <code>go.mod<\/code> dosyas\u0131n\u0131 kodunuzda ger\u00e7ekten kullan\u0131lan ba\u011f\u0131ml\u0131l\u0131klar\u0131 yans\u0131tacak \u015fekilde g\u00fcnceller ve <code>go.sum<\/code> dosyas\u0131n\u0131 da buna g\u00f6re d\u00fczenler.<\/p>\n<h3>\u0130yi Paket Yaz\u0131m Uygulamalar\u0131<\/h3>\n<p>Etkili ve s\u00fcrd\u00fcr\u00fclebilir Go paketleri yazmak i\u00e7in baz\u0131 en iyi uygulamalar\u0131 takip etmek \u00f6nemlidir.<\/p>\n<h4>Tek Sorumluluk Prensibi (Single Responsibility Principle &#8211; SRP)<\/h4>\n<p>Her paket, tek bir iyi tan\u0131mlanm\u0131\u015f sorumlulu\u011fa sahip olmal\u0131d\u0131r. Bir paket \u00e7ok fazla \u015fey yapmaya \u00e7al\u0131\u015f\u0131yorsa, muhtemelen birden fazla pakete ayr\u0131lmal\u0131d\u0131r. \u00d6rne\u011fin, bir <code>auth<\/code> paketi yaln\u0131zca kimlik do\u011frulama ve yetkilendirme ile ilgilenmeli, veritaban\u0131 i\u015flemleri veya HTTP sunucusu y\u00f6netimiyle de\u011fil. Bu, paketlerin daha k\u00fc\u00e7\u00fck, odaklanm\u0131\u015f ve y\u00f6netilebilir olmas\u0131n\u0131 sa\u011flar.<\/p>\n<h4>A\u00e7\u0131k ve Anla\u015f\u0131l\u0131r \u0130simlendirme<\/h4>\n<p>*   <strong>Paket \u0130simleri:<\/strong> K\u0131sa, k\u00fc\u00e7\u00fck harfli ve anlaml\u0131 olmal\u0131d\u0131r. Genellikle paketin yapt\u0131\u011f\u0131 i\u015fi yans\u0131tan tekil bir isim tercih edilir (\u00f6rn. <code>http<\/code>, <code>json<\/code>, <code>time<\/code>, <code>errors<\/code>, <code>strings<\/code>, <code>math<\/code>). <code>util<\/code> veya <code>common<\/code> gibi genel isimlerden ka\u00e7\u0131n\u0131n; bunlar genellikle SRP&#8217;nin ihlal edildi\u011finin bir i\u015faretidir.<br \/>\n*   <strong>D\u0131\u015fa Aktar\u0131lan Elemanlar:<\/strong> B\u00fcy\u00fck harfle ba\u015flamal\u0131 ve a\u00e7\u0131klay\u0131c\u0131 olmal\u0131d\u0131r (\u00f6rn. <code>GetUserByID<\/code>, <code>Config<\/code>, <code>ErrNotFound<\/code>).<br \/>\n*   <strong>D\u0131\u015fa Aktar\u0131lmayan Elemanlar:<\/strong> K\u00fc\u00e7\u00fck harfle ba\u015flamal\u0131 ve sadece paket i\u00e7inde ge\u00e7erli olmal\u0131d\u0131r.<\/p>\n<h4>Dok\u00fcmantasyon<\/h4>\n<p>Go&#8217;da dok\u00fcmantasyon, kodun \u00f6nemli bir par\u00e7as\u0131d\u0131r. Her d\u0131\u015fa aktar\u0131lan eleman (fonksiyon, tip, de\u011fi\u015fken, sabit) i\u00e7in a\u00e7\u0131klay\u0131c\u0131 yorumlar yaz\u0131lmal\u0131d\u0131r. Bu yorumlar <code>godoc<\/code> arac\u0131 taraf\u0131ndan okunur ve otomatik olarak dok\u00fcmantasyon olu\u015fturur.<\/p>\n<pre><code class=\"language-go\">\/\/ calculator\/calculator.go\n\n\/\/ Package calculator provides basic arithmetic operations.\npackage calculator\n\n\/\/ Add adds two integers and returns their sum.\nfunc Add(a, b int) int {\n    return a + b\n}\n\n\/\/ Result represents the outcome of an arithmetic operation.\ntype Result struct {\n    Value int\n    Error error\n}<\/code><\/pre>\n<p>Paket seviyesindeki yorumlar, <code>package<\/code> bildiriminin hemen \u00fcst\u00fcne yaz\u0131lmal\u0131 ve paketin ne i\u015fe yarad\u0131\u011f\u0131n\u0131 a\u00e7\u0131klamal\u0131d\u0131r.<\/p>\n<h4>Hata Y\u00f6netimi<\/h4>\n<p>Go&#8217;da hatalar, fonksiyonlar\u0131n son d\u00f6n\u00fc\u015f de\u011feri olarak <code>error<\/code> aray\u00fcz\u00fc tipiyle d\u00f6nd\u00fcr\u00fcl\u00fcr. Paketlerinizde anlaml\u0131 ve a\u00e7\u0131klay\u0131c\u0131 hata tipleri tan\u0131mlamak \u00f6nemlidir. \u00d6zel hata tipleri olu\u015fturarak, \u00e7a\u011f\u0131ran kodun hatay\u0131 daha spesifik bir \u015fekilde i\u015flemesini sa\u011flayabilirsiniz.<\/p>\n<pre><code class=\"language-go\">\/\/ calculator\/calculator.go\npackage calculator\n\nimport \"fmt\"\n\n\/\/ ErrDivisionByZero indicates an attempt to divide by zero.\nvar ErrDivisionByZero = fmt.Errorf(\"s\u0131f\u0131ra b\u00f6lme hatas\u0131\")\n\nfunc Divide(a, b int) (int, error) {\n    if b == 0 {\n        return 0, ErrDivisionByZero\n    }\n    return a \/ b, nil\n}<\/code><\/pre>\n<h4>Test Edilebilirlik<\/h4>\n<p>\u0130yi tasarlanm\u0131\u015f paketler kolayca test edilebilir olmal\u0131d\u0131r. Go, yerle\u015fik bir test \u00e7er\u00e7evesine sahiptir. Her Go paketi i\u00e7in, ayn\u0131 dizinde <code>_test.go<\/code> uzant\u0131l\u0131 bir dosya olu\u015fturularak testler yaz\u0131l\u0131r.<\/p>\n<pre><code class=\"language-go\">\/\/ calculator\/calculator_test.go\npackage calculator\n\nimport \"testing\"\n\nfunc TestAdd(t *testing.T) {\n    sum := Add(1, 2)\n    expected := 3\n    if sum != expected {\n        t.Errorf(\"Add(1, 2) beklenen %d, al\u0131nan %d\", expected, sum)\n    }\n}\n\nfunc TestDivide(t *testing.T) {\n    _, err := Divide(10, 0)\n    if err == nil {\n        t.Errorf(\"Divide(10, 0) bir hata d\u00f6nd\u00fcrmeliydi, ancak d\u00f6nd\u00fcrmedi.\")\n    }\n    if err != ErrDivisionByZero {\n        t.Errorf(\"Divide(10, 0) beklenen hata %v, al\u0131nan %v\", ErrDivisionByZero, err)\n    }\n\n    result, err := Divide(10, 2)\n    if err != nil {\n        t.Errorf(\"Divide(10, 2) hata d\u00f6nd\u00fcrmemeliydi: %v\", err)\n    }\n    if result != 5 {\n        t.Errorf(\"Divide(10, 2) beklenen 5, al\u0131nan %d\", result)\n    }\n}<\/code><\/pre>\n<p>Testleri \u00e7al\u0131\u015ft\u0131rmak i\u00e7in paket dizininde <code>go test<\/code> komutu kullan\u0131l\u0131r.<\/p>\n<h4>Ba\u011f\u0131ml\u0131l\u0131k Y\u00f6netimi (Minimize Dependencies)<\/h4>\n<p>Paketlerinizin m\u00fcmk\u00fcn oldu\u011funca az harici ba\u011f\u0131ml\u0131l\u0131\u011fa sahip olmas\u0131 iyi bir uygulamad\u0131r. Her yeni ba\u011f\u0131ml\u0131l\u0131k, projenizin karma\u015f\u0131kl\u0131\u011f\u0131n\u0131 ve potansiyel g\u00fcvenlik a\u00e7\u0131klar\u0131n\u0131 art\u0131r\u0131r. E\u011fer bir i\u015flevsellik Go standart k\u00fct\u00fcphanesi ile sa\u011flanabiliyorsa, harici bir k\u00fct\u00fcphane kullanmaktan ka\u00e7\u0131n\u0131n.<\/p>\n<h4>API Tasar\u0131m\u0131<\/h4>\n<p>Paketinizin d\u0131\u015fa aktard\u0131\u011f\u0131 aray\u00fcz (API) basit, sezgisel ve kararl\u0131 olmal\u0131d\u0131r. D\u0131\u015fa aktar\u0131lan fonksiyonlar\u0131n ve tiplerin kullan\u0131m\u0131 kolay olmal\u0131 ve gelecekteki de\u011fi\u015fikliklerden en az etkilenmelidir. Bir paketin API&#8217;si, o paketin &#8220;s\u00f6zle\u015fmesi&#8221;dir.<\/p>\n<h4>G\u00f6r\u00fcn\u00fcrl\u00fck (Export Only What&#8217;s Necessary)<\/h4>\n<p>Sadece di\u011fer paketler taraf\u0131ndan kullan\u0131lmas\u0131 gereken elemanlar\u0131 d\u0131\u015fa aktar\u0131n. Dahili implementasyon detaylar\u0131n\u0131 d\u0131\u015fa aktarmaktan ka\u00e7\u0131n\u0131n. Bu, paketin i\u00e7 yap\u0131s\u0131n\u0131 de\u011fi\u015ftirirken d\u0131\u015far\u0131daki kodu bozma riskini azalt\u0131r ve paketin API&#8217;sini temiz tutar.<\/p>\n<h3>Geli\u015fmi\u015f Konulara K\u0131sa Bir Bak\u0131\u015f<\/h3>\n<p>Go paketleri hakk\u0131nda daha derinlemesine bilgi edinmek isteyenler i\u00e7in baz\u0131 ileri d\u00fczey konular \u015funlard\u0131r:<\/p>\n<p>*   <strong>Build Tags:<\/strong> Farkl\u0131 i\u015fletim sistemleri veya mimariler i\u00e7in farkl\u0131 kod par\u00e7alar\u0131n\u0131 derlemek \u00fczere kullan\u0131l\u0131r. \u00d6rne\u011fin, <code>\/\/ +build linux<\/code> etiketi, o dosyan\u0131n yaln\u0131zca Linux&#8217;ta derlenmesini sa\u011flar.<br \/>\n*   <strong>Internal Paketler:<\/strong> Go 1.4 ile tan\u0131t\u0131lan <code>internal<\/code> dizini, bir paketin i\u00e7indeki kodun sadece o mod\u00fcl i\u00e7inde kullan\u0131labilmesini sa\u011flar, d\u0131\u015f mod\u00fcllerden eri\u015filemez. \u00d6rne\u011fin, <code>myproject\/internal\/cache<\/code> paketi, sadece <code>myproject<\/code> mod\u00fcl\u00fc i\u00e7indeki di\u011fer paketler taraf\u0131ndan kullan\u0131labilir.<br \/>\n*   <strong>CGO:<\/strong> Go kodundan C kodunu \u00e7a\u011f\u0131rmak veya C kodunu Go&#8217;ya ba\u011flamak i\u00e7in kullan\u0131l\u0131r. \u00d6zellikle sistem seviyesi programlama veya mevcut C k\u00fct\u00fcphanelerini kullanmak gerekti\u011finde faydal\u0131d\u0131r.<br \/>\n*   <strong>Kod \u00dcretimi (Code Generation):<\/strong> <code>stringer<\/code> gibi ara\u00e7lar veya \u00f6zel <code>go generate<\/code> komutlar\u0131 kullanarak kodunuzu otomatik olarak \u00fcretebilirsiniz. Bu, tekrar eden kod yazma ihtiyac\u0131n\u0131 azalt\u0131r ve hatalar\u0131 \u00f6nler.<\/p>\n<h3>\u00d6rnek Uygulama: Bir G\u00f6rev Y\u00f6neticisi Mod\u00fcl\u00fc<\/h3>\n<p>\u00c7oklu paketlerin nas\u0131l bir araya geldi\u011fini g\u00f6stermek i\u00e7in basit bir g\u00f6rev y\u00f6neticisi mod\u00fcl\u00fc olu\u015ftural\u0131m.<\/p>\n<pre><code class=\"language-\">taskmanager\/\n\u251c\u2500\u2500 go.mod\n\u251c\u2500\u2500 main.go\n\u251c\u2500\u2500 task\/\n\u2502   \u2514\u2500\u2500 task.go\n\u2514\u2500\u2500 storage\/\n    \u2514\u2500\u2500 memory.go<\/code><\/pre>\n<p><strong>1. <code>go.mod<\/code> dosyas\u0131n\u0131 ba\u015flat\u0131n:<\/strong><\/p>\n<pre><code class=\"language-bash\">mkdir taskmanager\ncd taskmanager\ngo mod init example.com\/taskmanager<\/code><\/pre>\n<p><strong>2. <code>task<\/code> paketi (<code>task\/task.go<\/code>):<\/strong><\/p>\n<pre><code class=\"language-go\">\/\/ task\/task.go\npackage task\n\nimport (\n    \"fmt\"\n    \"time\"\n)\n\n\/\/ Task represents a single task in the task manager.\ntype Task struct {\n    ID          string\n    Description string\n    IsCompleted bool\n    CreatedAt   time.Time\n}\n\n\/\/ NewTask creates a new Task instance.\nfunc NewTask(id, description string) *Task {\n    return &Task{\n        ID:          id,\n        Description: description,\n        IsCompleted: false,\n        CreatedAt:   time.Now(),\n    }\n}\n\n\/\/ Complete marks the task as completed.\nfunc (t *Task) Complete() {\n    t.IsCompleted = true\n}\n\n\/\/ String provides a string representation of the Task.\nfunc (t *Task) String() string {\n    status := \"Beklemede\"\n    if t.IsCompleted {\n        status = \"Tamamland\u0131\"\n    }\n    return fmt.Sprintf(\"ID: %s, A\u00e7\u0131klama: '%s', Durum: %s, Olu\u015fturulma: %s\",\n        t.ID, t.Description, status, t.CreatedAt.Format(\"2006-01-02 15:04:05\"))\n}<\/code><\/pre>\n<p><strong>3. <code>storage<\/code> paketi (<code>storage\/memory.go<\/code>):<\/strong><br \/>\nBu paket, g\u00f6revleri bellekte saklayacak basit bir depolama mekanizmas\u0131 sa\u011flar.<\/p>\n<pre><code class=\"language-go\">\/\/ storage\/memory.go\npackage storage\n\nimport (\n    \"fmt\"\n    \"sync\"\n\n    \"example.com\/taskmanager\/task\" \/\/ task paketini import ediyoruz\n)\n\n\/\/ Store defines the interface for task storage.\ntype Store interface {\n    AddTask(t *task.Task) error\n    GetTask(id string) (*task.Task, error)\n    GetAllTasks() []*task.Task\n    UpdateTask(t *task.Task) error\n    DeleteTask(id string) error\n}\n\n\/\/ MemoryStore is an in-memory implementation of the Store interface.\ntype MemoryStore struct {\n    tasks map[string]*task.Task\n    mu    sync.RWMutex \/\/ E\u015fzamanl\u0131 eri\u015fim i\u00e7in mutex\n}\n\n\/\/ NewMemoryStore creates a new MemoryStore.\nfunc NewMemoryStore() *MemoryStore {\n    return &MemoryStore{\n        tasks: make(map[string]*task.Task),\n    }\n}\n\n\/\/ AddTask adds a new task to the store.\nfunc (s <em>MemoryStore) AddTask(t <\/em>task.Task) error {\n    s.mu.Lock()\n    defer s.mu.Unlock()\n    if _, exists := s.tasks[t.ID]; exists {\n        return fmt.Errorf(\"ID %s zaten mevcut\", t.ID)\n    }\n    s.tasks[t.ID] = t\n    return nil\n}\n\n\/\/ GetTask retrieves a task by its ID.\nfunc (s <em>MemoryStore) GetTask(id string) (<\/em>task.Task, error) {\n    s.mu.RLock()\n    defer s.mu.RUnlock()\n    t, exists := s.tasks[id]\n    if !exists {\n        return nil, fmt.Errorf(\"ID %s ile g\u00f6rev bulunamad\u0131\", id)\n    }\n    return t, nil\n}\n\n\/\/ GetAllTasks retrieves all tasks in the store.\nfunc (s <em>MemoryStore) GetAllTasks() []<\/em>task.Task {\n    s.mu.RLock()\n    defer s.mu.RUnlock()\n    allTasks := make([]*task.Task, 0, len(s.tasks))\n    for _, t := range s.tasks {\n        allTasks = append(allTasks, t)\n    }\n    return allTasks\n}\n\n\/\/ UpdateTask updates an existing task.\nfunc (s <em>MemoryStore) UpdateTask(t <\/em>task.Task) error {\n    s.mu.Lock()\n    defer s.mu.Unlock()\n    if _, exists := s.tasks[t.ID]; !exists {\n        return fmt.Errorf(\"ID %s ile g\u00f6rev bulunamad\u0131, g\u00fcncellenemedi\", t.ID)\n    }\n    s.tasks[t.ID] = t\n    return nil\n}\n\n\/\/ DeleteTask deletes a task by its ID.\nfunc (s *MemoryStore) DeleteTask(id string) error {\n    s.mu.Lock()\n    defer s.mu.Unlock()\n    if _, exists := s.tasks[id]; !exists {\n        return fmt.Errorf(\"ID %s ile g\u00f6rev bulunamad\u0131, silinemedi\", id)\n    }\n    delete(s.tasks, id)\n    return nil\n}<\/code><\/pre>\n<p><strong>4. <code>main<\/code> paketi (<code>main.go<\/code>):<\/strong><\/p>\n<pre><code class=\"language-go\">\/\/ main.go\npackage main\n\nimport (\n    \"fmt\"\n    \"log\"\n\n    \"example.com\/taskmanager\/storage\" \/\/ storage paketini import ediyoruz\n    \"example.com\/taskmanager\/task\"    \/\/ task paketini import ediyoruz\n)\n\nfunc main() {\n    \/\/ Bellek tabanl\u0131 depolama olu\u015ftur\n    store := storage.NewMemoryStore()\n\n    \/\/ Yeni g\u00f6revler olu\u015ftur\n    task1 := task.NewTask(\"1\", \"Go paketi yazma makalesini bitir\")\n    task2 := task.NewTask(\"2\", \"Al\u0131\u015fveri\u015f yap\")\n    task3 := task.NewTask(\"3\", \"Spor yap\")\n\n    \/\/ G\u00f6revleri depolamaya ekle\n    if err := store.AddTask(task1); err != nil {\n        log.Fatalf(\"G\u00f6rev eklenirken hata olu\u015ftu: %v\", err)\n    }\n    if err := store.AddTask(task2); err != nil {\n        log.Fatalf(\"G\u00f6rev eklenirken hata olu\u015ftu: %v\", err)\n    }\n    if err := store.AddTask(task3); err != nil {\n        log.Fatalf(\"G\u00f6rev eklenirken hata olu\u015ftu: %v\", err)\n    }\n\n    fmt.Println(\"--- T\u00fcm G\u00f6revler ---\")\n    printAllTasks(store)\n\n    \/\/ Bir g\u00f6revi tamamla\n    task1.Complete()\n    if err := store.UpdateTask(task1); err != nil {\n        log.Fatalf(\"G\u00f6rev g\u00fcncellenirken hata olu\u015ftu: %v\", err)\n    }\n    fmt.Printf(\"\\n--- G\u00f6rev '%s' tamamland\u0131 ---\\n\", task1.Description)\n    printAllTasks(store)\n\n    \/\/ Bir g\u00f6revi sil\n    if err := store.DeleteTask(\"2\"); err != nil {\n        log.Fatalf(\"G\u00f6rev silinirken hata olu\u015ftu: %v\", err)\n    }\n    fmt.Println(\"\\n--- G\u00f6rev 'Al\u0131\u015fveri\u015f yap' silindi ---\")\n    printAllTasks(store)\n\n    \/\/ Belirli bir g\u00f6revi getir\n    retrievedTask, err := store.GetTask(\"3\")\n    if err != nil {\n        log.Fatalf(\"G\u00f6rev getirilirken hata olu\u015ftu: %v\", err)\n    }\n    fmt.Printf(\"\\n--- Getirilen G\u00f6rev: %s ---\\n\", retrievedTask)\n}\n\nfunc printAllTasks(store storage.Store) {\n    tasks := store.GetAllTasks()\n    if len(tasks) == 0 {\n        fmt.Println(\"Hi\u00e7 g\u00f6rev yok.\")\n        return\n    }\n    for _, t := range tasks {\n        fmt.Println(t)\n    }\n}<\/code><\/pre>\n<p>Bu \u00f6rnek, <code>task<\/code> ve <code>storage<\/code> olmak \u00fczere iki farkl\u0131 paketin nas\u0131l tan\u0131mland\u0131\u011f\u0131n\u0131 ve <code>main<\/code> paketinde nas\u0131l bir araya getirildi\u011fini g\u00f6steriyor. <code>task<\/code> paketi g\u00f6rev nesnesinin yap\u0131s\u0131n\u0131 ve davran\u0131\u015flar\u0131n\u0131 tan\u0131mlarken, <code>storage<\/code> paketi bu g\u00f6revleri saklama ve y\u00f6netme sorumlulu\u011funu \u00fcstleniyor. Bu, sorumluluklar\u0131n ayr\u0131lmas\u0131na ve kodun daha mod\u00fcler olmas\u0131na olanak tan\u0131r.<\/p>\n<p>\u00c7al\u0131\u015ft\u0131rmak i\u00e7in <code>taskmanager<\/code> dizininde:<\/p>\n<pre><code class=\"language-bash\">go run main.go<\/code><\/pre>\n<h3>Sonu\u00e7<\/h3>\n<p>Go&#8217;da paketler, kod organizasyonunun, yeniden kullan\u0131labilirli\u011fin ve s\u00fcrd\u00fcr\u00fclebilirli\u011fin temelini olu\u015fturur. Mod\u00fcler Go uygulamalar\u0131 geli\u015ftirmek i\u00e7in paketlerin nas\u0131l \u00e7al\u0131\u015ft\u0131\u011f\u0131n\u0131, nas\u0131l olu\u015fturuldu\u011funu ve en iyi uygulamalarla nas\u0131l tasarlanmas\u0131 gerekti\u011fini anlamak hayati \u00f6neme sahiptir. Tek sorumluluk prensibini benimseyerek, a\u00e7\u0131k isimler kullanarak, iyi dok\u00fcmantasyon sa\u011flayarak ve test edilebilir kod yazarak, hem kendi projelerinizde hem de a\u00e7\u0131k kaynak toplulu\u011funda de\u011ferli ve bak\u0131m\u0131 kolay Go paketleri olu\u015fturabilirsiniz. Go Mod\u00fclleri ile ba\u011f\u0131ml\u0131l\u0131k y\u00f6netimi de b\u00fcy\u00fck \u00f6l\u00e7\u00fcde basitle\u015fmi\u015f ve Go geli\u015ftirme deneyimini daha keyifli hale getirmi\u015ftir. Bu rehberdeki bilgileri kullanarak, Go&#8217;da sa\u011flam ve \u00f6l\u00e7eklenebilir uygulamalar geli\u015ftirmek i\u00e7in ilk ad\u0131m\u0131 atm\u0131\u015f olacaks\u0131n\u0131z.<\/body><\/p>\n","protected":false},"excerpt":{"rendered":"Go&#8217;da Paket Yaz\u0131m\u0131: Kapsaml\u0131 Bir Rehber\nGo programlama dili, mod\u00fclerlik, yeniden kullan\u0131labilirlik ve kod organizasyonu konular\u0131nda paketlere b","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"csco_page_header_type":"","csco_page_load_nextpost":"","csco_page_subscribe_form":"","csco_page_contact_form":"","footnotes":""},"categories":[1],"tags":[],"class_list":{"0":"post-33654","1":"post","2":"type-post","3":"status-publish","4":"format-standard","6":"category-genel","7":"cs-entry","8":"cs-video-wrap"},"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v20.5 (Yoast SEO v25.3.1) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Go&#039;da Paket Yaz\u0131m\u0131: Kapsaml\u0131 Bir Rehber - Kodlar\u0131n Gizemli D\u00fcnyas\u0131<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/fatihsoysal.com\/blog\/goda-paket-yazimi-kapsamli-bir-rehber\/\" \/>\n<meta property=\"og:locale\" content=\"tr_TR\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Go&#039;da Paket Yaz\u0131m\u0131: Kapsaml\u0131 Bir Rehber\" \/>\n<meta property=\"og:description\" content=\"Go&#039;da Paket Yaz\u0131m\u0131: Kapsaml\u0131 Bir Rehber Go programlama dili, mod\u00fclerlik, yeniden kullan\u0131labilirlik ve kod organizasyonu konular\u0131nda paketlere b\" \/>\n<meta property=\"og:url\" content=\"https:\/\/fatihsoysal.com\/blog\/goda-paket-yazimi-kapsamli-bir-rehber\/\" \/>\n<meta property=\"og:site_name\" content=\"Kodlar\u0131n Gizemli D\u00fcnyas\u0131\" \/>\n<meta property=\"article:published_time\" content=\"2025-11-05T11:40:53+00:00\" \/>\n<meta name=\"author\" content=\"Fatih Soysal\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Yazan:\" \/>\n\t<meta name=\"twitter:data1\" content=\"Fatih Soysal\" \/>\n\t<meta name=\"twitter:label2\" content=\"Tahmini okuma s\u00fcresi\" \/>\n\t<meta name=\"twitter:data2\" content=\"20 dakika\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/fatihsoysal.com\/blog\/goda-paket-yazimi-kapsamli-bir-rehber\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/fatihsoysal.com\/blog\/goda-paket-yazimi-kapsamli-bir-rehber\/\"},\"author\":{\"name\":\"Fatih Soysal\",\"@id\":\"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/002a254750921dcfd568a99e48240dd1\"},\"headline\":\"Go&#8217;da Paket Yaz\u0131m\u0131: Kapsaml\u0131 Bir Rehber\",\"datePublished\":\"2025-11-05T11:40:53+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/fatihsoysal.com\/blog\/goda-paket-yazimi-kapsamli-bir-rehber\/\"},\"wordCount\":2499,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/002a254750921dcfd568a99e48240dd1\"},\"inLanguage\":\"tr\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/fatihsoysal.com\/blog\/goda-paket-yazimi-kapsamli-bir-rehber\/#respond\"]}],\"copyrightYear\":\"2025\",\"copyrightHolder\":{\"@id\":\"https:\/\/fatihsoysal.com\/blog\/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/fatihsoysal.com\/blog\/goda-paket-yazimi-kapsamli-bir-rehber\/\",\"url\":\"https:\/\/fatihsoysal.com\/blog\/goda-paket-yazimi-kapsamli-bir-rehber\/\",\"name\":\"Go'da Paket Yaz\u0131m\u0131: Kapsaml\u0131 Bir Rehber - Kodlar\u0131n Gizemli D\u00fcnyas\u0131\",\"isPartOf\":{\"@id\":\"https:\/\/fatihsoysal.com\/blog\/#website\"},\"datePublished\":\"2025-11-05T11:40:53+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/fatihsoysal.com\/blog\/goda-paket-yazimi-kapsamli-bir-rehber\/#breadcrumb\"},\"inLanguage\":\"tr\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/fatihsoysal.com\/blog\/goda-paket-yazimi-kapsamli-bir-rehber\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/fatihsoysal.com\/blog\/goda-paket-yazimi-kapsamli-bir-rehber\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Anasayfa\",\"item\":\"https:\/\/fatihsoysal.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Go&#8217;da Paket Yaz\u0131m\u0131: Kapsaml\u0131 Bir Rehber\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/fatihsoysal.com\/blog\/#website\",\"url\":\"https:\/\/fatihsoysal.com\/blog\/\",\"name\":\"Fatihsoysal.com\",\"description\":\"Blog - Yaz\u0131l\u0131m D\u00fcnyas\u0131 Tecr\u00fcbelerim\",\"publisher\":{\"@id\":\"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/002a254750921dcfd568a99e48240dd1\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/fatihsoysal.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"tr\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/002a254750921dcfd568a99e48240dd1\",\"name\":\"Fatih Soysal\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"tr\",\"@id\":\"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/fatihsoysal.com\/blog\/wp-content\/uploads\/2024\/04\/cropped-replicate-prediction-3kgg1hgjn5rgp0cf0p5tr0jw7w-1.png\",\"contentUrl\":\"https:\/\/fatihsoysal.com\/blog\/wp-content\/uploads\/2024\/04\/cropped-replicate-prediction-3kgg1hgjn5rgp0cf0p5tr0jw7w-1.png\",\"width\":512,\"height\":512,\"caption\":\"Fatih Soysal\"},\"logo\":{\"@id\":\"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/image\/\"},\"description\":\"Kullan\u0131m ve kodlama m\u00fckemmeliyetini odak alan uygulamalar olu\u015fturma deneyimine sahip, profesyonel olarak 15+ y\u0131l \u00fczeri deneyime sahip bir yaz\u0131l\u0131m m\u00fchendisi.\",\"url\":\"https:\/\/fatihsoysal.com\/blog\/author\/fatihsoysal\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Go'da Paket Yaz\u0131m\u0131: Kapsaml\u0131 Bir Rehber - Kodlar\u0131n Gizemli D\u00fcnyas\u0131","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/fatihsoysal.com\/blog\/goda-paket-yazimi-kapsamli-bir-rehber\/","og_locale":"tr_TR","og_type":"article","og_title":"Go'da Paket Yaz\u0131m\u0131: Kapsaml\u0131 Bir Rehber","og_description":"Go'da Paket Yaz\u0131m\u0131: Kapsaml\u0131 Bir Rehber Go programlama dili, mod\u00fclerlik, yeniden kullan\u0131labilirlik ve kod organizasyonu konular\u0131nda paketlere b","og_url":"https:\/\/fatihsoysal.com\/blog\/goda-paket-yazimi-kapsamli-bir-rehber\/","og_site_name":"Kodlar\u0131n Gizemli D\u00fcnyas\u0131","article_published_time":"2025-11-05T11:40:53+00:00","author":"Fatih Soysal","twitter_card":"summary_large_image","twitter_misc":{"Yazan:":"Fatih Soysal","Tahmini okuma s\u00fcresi":"20 dakika"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/fatihsoysal.com\/blog\/goda-paket-yazimi-kapsamli-bir-rehber\/#article","isPartOf":{"@id":"https:\/\/fatihsoysal.com\/blog\/goda-paket-yazimi-kapsamli-bir-rehber\/"},"author":{"name":"Fatih Soysal","@id":"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/002a254750921dcfd568a99e48240dd1"},"headline":"Go&#8217;da Paket Yaz\u0131m\u0131: Kapsaml\u0131 Bir Rehber","datePublished":"2025-11-05T11:40:53+00:00","mainEntityOfPage":{"@id":"https:\/\/fatihsoysal.com\/blog\/goda-paket-yazimi-kapsamli-bir-rehber\/"},"wordCount":2499,"commentCount":0,"publisher":{"@id":"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/002a254750921dcfd568a99e48240dd1"},"inLanguage":"tr","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/fatihsoysal.com\/blog\/goda-paket-yazimi-kapsamli-bir-rehber\/#respond"]}],"copyrightYear":"2025","copyrightHolder":{"@id":"https:\/\/fatihsoysal.com\/blog\/#organization"}},{"@type":"WebPage","@id":"https:\/\/fatihsoysal.com\/blog\/goda-paket-yazimi-kapsamli-bir-rehber\/","url":"https:\/\/fatihsoysal.com\/blog\/goda-paket-yazimi-kapsamli-bir-rehber\/","name":"Go'da Paket Yaz\u0131m\u0131: Kapsaml\u0131 Bir Rehber - Kodlar\u0131n Gizemli D\u00fcnyas\u0131","isPartOf":{"@id":"https:\/\/fatihsoysal.com\/blog\/#website"},"datePublished":"2025-11-05T11:40:53+00:00","breadcrumb":{"@id":"https:\/\/fatihsoysal.com\/blog\/goda-paket-yazimi-kapsamli-bir-rehber\/#breadcrumb"},"inLanguage":"tr","potentialAction":[{"@type":"ReadAction","target":["https:\/\/fatihsoysal.com\/blog\/goda-paket-yazimi-kapsamli-bir-rehber\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/fatihsoysal.com\/blog\/goda-paket-yazimi-kapsamli-bir-rehber\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Anasayfa","item":"https:\/\/fatihsoysal.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Go&#8217;da Paket Yaz\u0131m\u0131: Kapsaml\u0131 Bir Rehber"}]},{"@type":"WebSite","@id":"https:\/\/fatihsoysal.com\/blog\/#website","url":"https:\/\/fatihsoysal.com\/blog\/","name":"Fatihsoysal.com","description":"Blog - Yaz\u0131l\u0131m D\u00fcnyas\u0131 Tecr\u00fcbelerim","publisher":{"@id":"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/002a254750921dcfd568a99e48240dd1"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/fatihsoysal.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"tr"},{"@type":["Person","Organization"],"@id":"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/002a254750921dcfd568a99e48240dd1","name":"Fatih Soysal","image":{"@type":"ImageObject","inLanguage":"tr","@id":"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/fatihsoysal.com\/blog\/wp-content\/uploads\/2024\/04\/cropped-replicate-prediction-3kgg1hgjn5rgp0cf0p5tr0jw7w-1.png","contentUrl":"https:\/\/fatihsoysal.com\/blog\/wp-content\/uploads\/2024\/04\/cropped-replicate-prediction-3kgg1hgjn5rgp0cf0p5tr0jw7w-1.png","width":512,"height":512,"caption":"Fatih Soysal"},"logo":{"@id":"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/image\/"},"description":"Kullan\u0131m ve kodlama m\u00fckemmeliyetini odak alan uygulamalar olu\u015fturma deneyimine sahip, profesyonel olarak 15+ y\u0131l \u00fczeri deneyime sahip bir yaz\u0131l\u0131m m\u00fchendisi.","url":"https:\/\/fatihsoysal.com\/blog\/author\/fatihsoysal\/"}]}},"yoast_meta":{"yoast_wpseo_title":"","yoast_wpseo_metadesc":"","yoast_wpseo_canonical":""},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/fatihsoysal.com\/blog\/wp-json\/wp\/v2\/posts\/33654","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fatihsoysal.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fatihsoysal.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fatihsoysal.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fatihsoysal.com\/blog\/wp-json\/wp\/v2\/comments?post=33654"}],"version-history":[{"count":1,"href":"https:\/\/fatihsoysal.com\/blog\/wp-json\/wp\/v2\/posts\/33654\/revisions"}],"predecessor-version":[{"id":33655,"href":"https:\/\/fatihsoysal.com\/blog\/wp-json\/wp\/v2\/posts\/33654\/revisions\/33655"}],"wp:attachment":[{"href":"https:\/\/fatihsoysal.com\/blog\/wp-json\/wp\/v2\/media?parent=33654"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fatihsoysal.com\/blog\/wp-json\/wp\/v2\/categories?post=33654"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fatihsoysal.com\/blog\/wp-json\/wp\/v2\/tags?post=33654"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}