<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Yakuter</title>
	<atom:link href="https://www.yakuter.com/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.yakuter.com/</link>
	<description>biri kod mu dedi?</description>
	<lastBuildDate>Wed, 19 Aug 2026 08:16:38 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.1.4</generator>
	<item>
		<title>How I Stopped Cursor from Using 72 GB of Memory</title>
		<link>https://www.yakuter.com/how-i-stopped-cursor-from-using-72-gb-of-memory/</link>
					<comments>https://www.yakuter.com/how-i-stopped-cursor-from-using-72-gb-of-memory/#respond</comments>
		
		<dc:creator><![CDATA[Erhan Yakut]]></dc:creator>
		<pubDate>Wed, 19 Aug 2026 08:06:39 +0000</pubDate>
				<category><![CDATA[Yazılım]]></category>
		<guid isPermaLink="false">https://www.yakuter.com/how-i-stopped-cursor-from-using-82-gb-of-memory/</guid>

					<description><![CDATA[<p>Cursor reached nearly 72 GB of application memory on my Mac. Here is what caused it and the practical steps I used to stop it from happening again.</p>
<p><a href="https://www.yakuter.com/how-i-stopped-cursor-from-using-72-gb-of-memory/">How I Stopped Cursor from Using 72 GB of Memory</a> yazısı ilk önce <a href="https://www.yakuter.com">Yakuter</a> üzerinde ortaya çıktı.</p>
]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">I knew something was wrong when macOS displayed the “Your system has run out of application memory” warning. Cursor was using more than 72 GB in the screenshot. After restarting it, the memory usage quickly climbed above 8 GB again. This was not normal editor usage, so I investigated the running processes, local chat storage, file watchers, and workspace configuration. Here is what I found and how you can prevent the same problem.</p>



<h2 class="wp-block-heading">What Was Causing It?</h2>



<p class="wp-block-paragraph">There was no single cause. Several problems were multiplying each other:</p>



<ul class="wp-block-list">
<li>Cursor’s local chat database had grown to 9.1 GB.</li>



<li>Hundreds of Agent conversations and checkpoints were stored locally.</li>



<li>Old Cursor Helper processes remained alive after Cursor was closed.</li>



<li>A large multi-root workspace contained nine repositories.</li>



<li>My home directory was also open as a workspace.</li>



<li>Multiple Agent windows, language servers, and MCP servers were running.</li>



<li>Watchman was still monitoring old repositories and Agent worktrees.</li>
</ul>



<p class="wp-block-paragraph">Together, these caused Cursor’s renderer and helper processes to consume an extreme amount of memory.</p>



<h2 class="wp-block-heading">Step 1: Quit Cursor Completely</h2>



<p class="wp-block-paragraph">Closing a Cursor window does not always quit the application. Use <strong>Cmd+Q</strong> on macOS. It is also a good idea to restart Cursor regularly instead of leaving it running for several days.</p>



<p class="wp-block-paragraph">After quitting, check whether any Cursor processes remain:</p>



<pre class="wp-block-code"><code>ps -eo pid,ppid,rss,etime,command | awk '(/\/Applications\/Cursor\.app/ || /Cursor Helper/) &amp;&amp; !/awk/ &amp;&amp; !/CursorUIViewService/'</code></pre>



<p class="wp-block-paragraph">If the command returns nothing, Cursor has stopped correctly. If you still see processes whose parent process ID (<code>PPID</code>) is <code>1</code>, they are orphaned processes left behind by an earlier Cursor session.</p>



<h2 class="wp-block-heading">Step 2: Stop Orphaned Cursor Processes</h2>



<p class="wp-block-paragraph">First, try to stop them gracefully:</p>



<pre class="wp-block-code"><code>pkill -TERM -f '/Applications/Cursor.app|Cursor Helper'</code></pre>



<p class="wp-block-paragraph">Wait a few seconds and run the process check again. If the processes are still present, force-stop them:</p>



<pre class="wp-block-code"><code>killall -9 "Cursor Helper" "Cursor Helper (Plugin)" "Cursor Helper (Renderer)" Cursor 2&gt;/dev/null</code></pre>



<p class="wp-block-paragraph">Only run these commands while Cursor is closed. Otherwise, they will terminate your active Cursor session.</p>



<h2 class="wp-block-heading">Step 3: Check the Cursor Chat Database</h2>



<p class="wp-block-paragraph">Cursor stores Agent conversations, messages, checkpoints, and related data in a local SQLite database. On macOS, check its size with:</p>



<pre class="wp-block-code"><code>ls -lh ~/Library/Application\ Support/Cursor/User/globalStorage/state.vscdb</code></pre>



<p class="wp-block-paragraph">In my case, this file was <strong>9.1 GB</strong>. A closer inspection showed approximately 4.2 GB of chat message data, 3.2 GB of Agent key-value data, and 693 MB of checkpoints. A very large database increases disk usage and can also increase memory consumption when Cursor loads, searches, or renders conversation history.</p>



<h2 class="wp-block-heading">Step 4: Delete Old Chats from Cursor</h2>



<p class="wp-block-paragraph">Do not delete <code>state.vscdb</code> manually. Doing so can break Cursor’s chat index and leave old conversations stuck on “Loading Chat.”</p>



<p class="wp-block-paragraph">Use Cursor’s built-in cleanup commands:</p>



<ol class="wp-block-list">
<li>Open the Command Palette with <strong>Cmd+Shift+P</strong>.</li>



<li>Run <strong>Developer: Delete Old Chats…</strong></li>



<li>Select a retention period, such as 14 or 30 days.</li>



<li>Wait for the cleanup to finish.</li>



<li>Open the Command Palette again.</li>



<li>Run <strong>Developer: GC Agent KV Blobs</strong>.</li>
</ol>



<p class="wp-block-paragraph">The second command removes orphaned Agent data that is no longer connected to a visible chat. Run these commands once a month—or every two weeks if you use Agent heavily.</p>



<p class="wp-block-paragraph">Archiving or closing a chat is not the same as deleting it. To remove one conversation completely, open Chat History, click its three-dot menu, and select <strong>Delete</strong>.</p>



<h2 class="wp-block-heading">Step 5: Do Not Open Your Home Directory as a Workspace</h2>



<p class="wp-block-paragraph">Avoid opening paths such as:</p>



<pre class="wp-block-code"><code>/Users/your-name</code></pre>



<p class="wp-block-paragraph">This can make Cursor, extensions, and file watchers scan large folders such as <code>Library</code>, <code>Downloads</code>, application caches, package caches, virtual machines, and every project under your home directory. Open only the repository or folder you are actively working on.</p>



<h2 class="wp-block-heading">Step 6: Keep Workspaces Small</h2>



<p class="wp-block-paragraph">A workspace containing many large repositories may start multiple file watchers, Git processes, language servers, search services, and Cursor extension hosts. Instead of opening nine repositories in one workspace, create smaller workspaces for related projects. In most cases, opening one or two repositories is enough.</p>



<h2 class="wp-block-heading">Step 7: Close Unused Agent Windows</h2>



<p class="wp-block-paragraph">An Agent window is not free. It may run its own renderer, extension host, file watcher, and supporting services. Close unused Agent windows, empty Cursor windows, old background Agent sessions, and workspaces you are no longer using.</p>



<h2 class="wp-block-heading">Step 8: Disable Unused MCP Servers</h2>



<p class="wp-block-paragraph">Every enabled MCP integration may start another local process or maintain a remote connection. Disable browser automation, project-management integrations, communication tools, and other services when you do not need them. You can enable them again later.</p>



<h2 class="wp-block-heading">Step 9: Reset Old Watchman Watches</h2>



<p class="wp-block-paragraph">If you use Watchman, old repositories and temporary Agent worktrees may remain registered after Cursor closes. List the watched directories:</p>



<pre class="wp-block-code"><code>watchman watch-list</code></pre>



<p class="wp-block-paragraph">Remove all existing watches:</p>



<pre class="wp-block-code"><code>watchman watch-del-all</code></pre>



<p class="wp-block-paragraph">Cursor and your development tools will register the necessary directories again when they restart. If Watchman itself is stuck, stop it:</p>



<pre class="wp-block-code"><code>killall watchman 2&gt;/dev/null</code></pre>



<h2 class="wp-block-heading">Step 10: Exclude Generated and Dependency Folders</h2>



<p class="wp-block-paragraph">Large generated directories do not usually need to be watched or searched. Add suitable exclusions to your Cursor settings:</p>



<pre class="wp-block-code"><code>{
  "files.watcherExclude": {
    "**/.git/**": true,
    "**/node_modules/**": true,
    "**/dist/**": true,
    "**/build/**": true,
    "**/vendor/**": true,
    "**/.cache/**": true
  },
  "search.exclude": {
    "**/node_modules": true,
    "**/dist": true,
    "**/build": true,
    "**/vendor": true
  }
}</code></pre>



<p class="wp-block-paragraph">Adjust the list for your project. Do not exclude directories that contain source files you need Cursor to index.</p>



<h2 class="wp-block-heading">Step 11: Monitor Cursor’s Total Memory</h2>



<p class="wp-block-paragraph">Cursor is an Electron application. Its memory is spread across renderers, extension hosts, language servers, and file watchers. To see the total resident memory used by Cursor-related processes:</p>



<pre class="wp-block-code"><code>ps -axo rss,command | awk '/Cursor Helper|\/Applications\/Cursor\.app/ {total += $1} END {printf "Cursor RSS: %.2f GB\n", total / 1024 / 1024}'</code></pre>



<p class="wp-block-paragraph">The number shown by macOS may also include compressed or swapped application memory, so it can be higher than the machine’s physical RAM.</p>



<h2 class="wp-block-heading">A Simple Maintenance Routine</h2>



<ol class="wp-block-list">
<li>Quit Cursor with <strong>Cmd+Q</strong> at the end of the day.</li>



<li>Check for orphaned processes after a crash or Force Quit.</li>



<li>Delete old chats every few weeks.</li>



<li>Run <strong>GC Agent KV Blobs</strong> after deleting chats.</li>



<li>Open only the repositories you are actively using.</li>



<li>Keep Agent windows and MCP servers to a minimum.</li>



<li>Check <code>state.vscdb</code> before it grows into multiple gigabytes.</li>



<li>Reset stale Watchman watches when CPU usage looks unusual.</li>
</ol>



<h2 class="wp-block-heading">Final Thoughts</h2>



<p class="wp-block-paragraph">Cursor did not reach 72 GB because of one open source file. The real problem was accumulated Agent history combined with orphaned processes, oversized workspaces, file watchers, language servers, and extra integrations.</p>



<p class="wp-block-paragraph">Cursor can be a powerful development tool, but Agent-heavy workflows need occasional maintenance. A smaller workspace, a clean chat database, and a complete restart can make the difference between a responsive editor and a system-wide memory warning.</p>
<p><a href="https://www.yakuter.com/how-i-stopped-cursor-from-using-72-gb-of-memory/">How I Stopped Cursor from Using 72 GB of Memory</a> yazısı ilk önce <a href="https://www.yakuter.com">Yakuter</a> üzerinde ortaya çıktı.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.yakuter.com/how-i-stopped-cursor-from-using-72-gb-of-memory/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Designing an Endpoint Management Platform</title>
		<link>https://www.yakuter.com/designing-an-endpoint-management-platform/</link>
					<comments>https://www.yakuter.com/designing-an-endpoint-management-platform/#respond</comments>
		
		<dc:creator><![CDATA[Erhan Yakut]]></dc:creator>
		<pubDate>Fri, 30 Jan 2026 22:16:15 +0000</pubDate>
				<category><![CDATA[Golang]]></category>
		<category><![CDATA[Yazılım]]></category>
		<guid isPermaLink="false">https://www.yakuter.com/?p=2713</guid>

					<description><![CDATA[<p>Managing endpoints in enterprise environments is a recurring challenge. As organizations grow, manual operations become unmanageable, visibility decreases, and responding to incidents takes longer than it should. This presentation explores the design and live demonstration of a lightweight endpoint management platform built specifically for internal networks, focusing on clarity, reliability, and operational realism rather than [&#8230;]</p>
<p><a href="https://www.yakuter.com/designing-an-endpoint-management-platform/">Designing an Endpoint Management Platform</a> yazısı ilk önce <a href="https://www.yakuter.com">Yakuter</a> üzerinde ortaya çıktı.</p>
]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">Managing endpoints in enterprise environments is a recurring challenge. As organizations grow, manual operations become unmanageable, visibility decreases, and responding to incidents takes longer than it should. This presentation explores the design and live demonstration of a lightweight endpoint management platform built specifically for internal networks, focusing on clarity, reliability, and operational realism rather than over-engineering.</p>



<span id="more-2713"></span>



<h2 class="wp-block-heading">The Core Idea</h2>



<p class="wp-block-paragraph">The main goal of the project was simple: centrally manage endpoints and execute remote tasks in a controlled and predictable way. To achieve this, the system was designed around three core components: a web-based admin UI, a backend control API, and an endpoint agent running as a system service. Each component is independent, clearly scoped, and communicates using well-understood patterns.</p>



<h2 class="wp-block-heading">Agent-Based Architecture</h2>



<p class="wp-block-paragraph">At the heart of the platform is the endpoint agent. Instead of relying on server-initiated connections, the agent drives all communication. It periodically “visits” the backend, sends heartbeat information, checks for pending tasks, executes them if present, and returns results. This polling-based model is intentionally chosen to align with enterprise firewall realities, where inbound connections to endpoints are often restricted or outright blocked.</p>



<h2 class="wp-block-heading">Communication and Network Considerations</h2>



<p class="wp-block-paragraph">All communication is performed over HTTP. While more advanced protocols such as gRPC or MQTT could have been used, HTTP was selected for its predictability, firewall compatibility, and ease of inspection. In endpoint management, network acceptance and operational simplicity often matter more than raw protocol efficiency. By keeping communication outbound-only from the agent, the system remains compatible with even the most restrictive corporate environments.</p>



<h2 class="wp-block-heading">Backend Control API</h2>



<p class="wp-block-paragraph">The backend API is implemented using Go and the Gin framework. It is responsible for agent registration, heartbeat tracking, task assignment, and result collection. For demonstration purposes, the system uses in-memory data structures instead of persistent storage, keeping the focus on behavior and flow rather than infrastructure complexity. Despite its simplicity, the API reflects patterns commonly found in real-world endpoint management and security products.</p>



<h2 class="wp-block-heading">Web-Based Admin UI</h2>



<p class="wp-block-paragraph">The admin interface is built using a modern React stack and the shadcn-admin template. It provides a clear view of registered endpoints, including basic system information, online/offline status, and last seen timestamps. From the UI, operators can assign predefined tasks to endpoints and immediately observe results, reinforcing the end-to-end nature of the system.</p>



<h2 class="wp-block-heading">Agent Lifecycle and Self-Update</h2>



<p class="wp-block-paragraph">One of the more interesting aspects of the design is the agent’s self-update mechanism. On each visit, the agent checks whether a newer version is available. If an update is found, the agent downloads the new package, launches the installer as a separate process, and then intentionally terminates itself. The installer completes the update and restarts the service. This approach mirrors real-world endpoint products, where uninterrupted updates and resilience to service restarts are critical.</p>



<p class="wp-block-paragraph">To support this behavior, special care is taken to ensure that child processes survive agent termination. Platform-specific mechanisms are used on Windows, macOS, and Linux to detach updater processes from the parent service lifecycle.</p>



<h2 class="wp-block-heading">Endpoint Requirements and Operational Realities</h2>



<p class="wp-block-paragraph">Running an endpoint agent in practice requires more than just code. The platform assumes elevated permissions, including full disk access on macOS, to reliably perform file system operations. Additionally, when other security products are present on the endpoint, exclusions are often necessary to prevent interference, false positives, or blocked execution. These operational realities are an important part of the overall design and are explicitly addressed in the presentation.</p>



<h2 class="wp-block-heading">Conclusion</h2>



<p class="wp-block-paragraph">This project and presentation demonstrate that effective endpoint management does not require unnecessary complexity. By focusing on clear responsibilities, agent-driven communication, and enterprise-friendly design choices, it is possible to build a system that is both simple and realistic. While the demo implementation intentionally omits advanced security features, it provides a strong foundation and a clear path toward a production-ready platform.</p>



<p class="wp-block-paragraph">Ultimately, the goal was not just to build a demo, but to explore and explain the design decisions behind modern endpoint management systems—and to show how thoughtful architecture can make complex operational problems much more approachable.</p>
<p><a href="https://www.yakuter.com/designing-an-endpoint-management-platform/">Designing an Endpoint Management Platform</a> yazısı ilk önce <a href="https://www.yakuter.com">Yakuter</a> üzerinde ortaya çıktı.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.yakuter.com/designing-an-endpoint-management-platform/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Talking to the Kernel: Understanding How Software Communicates with the System</title>
		<link>https://www.yakuter.com/talking-to-the-kernel-understanding-how-software-communicates-with-the-system/</link>
					<comments>https://www.yakuter.com/talking-to-the-kernel-understanding-how-software-communicates-with-the-system/#respond</comments>
		
		<dc:creator><![CDATA[Erhan Yakut]]></dc:creator>
		<pubDate>Sat, 18 Oct 2025 19:21:10 +0000</pubDate>
				<category><![CDATA[Genel]]></category>
		<guid isPermaLink="false">https://www.yakuter.com/?p=2702</guid>

					<description><![CDATA[<p>Every time a program runs — when you open a file, start a process, or send a network packet — something much deeper happens beneath the surface. Your code doesn’t talk to the hardware directly; it communicates through a powerful layer called the kernel. The kernel is the silent mediator between software and the physical [&#8230;]</p>
<p><a href="https://www.yakuter.com/talking-to-the-kernel-understanding-how-software-communicates-with-the-system/">Talking to the Kernel: Understanding How Software Communicates with the System</a> yazısı ilk önce <a href="https://www.yakuter.com">Yakuter</a> üzerinde ortaya çıktı.</p>
]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">Every time a program runs — when you open a file, start a process, or send a network packet — something much deeper happens beneath the surface. Your code doesn’t talk to the hardware directly; it communicates through a powerful layer called the <strong>kernel</strong>.</p>



<p class="wp-block-paragraph">The kernel is the silent mediator between software and the physical world. It decides when your program gets CPU time, where memory is allocated, how data travels across the network, and which files can be accessed.<br><br>In many ways, the kernel is the <em>operating system itself</em> — everything else is built around it. But how does this communication actually happen? How does a high-level Go program like <code>os.Open("file.txt")</code> eventually cause a hard drive to spin or an SSD to read data?<br><br>This post dives into the mechanisms behind that conversation — exploring <strong>system calls</strong>, <strong>processes</strong>, <strong>file descriptors</strong>, and <strong>network interfaces</strong> — to reveal how our code “talks to the kernel.”</p>



<span id="more-2702"></span>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<h2 class="wp-block-heading"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f9e0.png" alt="🧠" class="wp-smiley" style="height: 1em; max-height: 1em;" /> What Is the Kernel?</h2>



<p class="wp-block-paragraph">Every operating system has a brain — the <strong>kernel</strong>.<br>It’s the invisible layer that connects user applications to the hardware.<br>Whenever a program opens a file, creates a process, or sends a network packet, it doesn’t interact with the hardware directly — it talks to the kernel.</p>



<p class="wp-block-paragraph">The kernel manages CPU scheduling, memory, file systems, and device I/O.<br>It provides a safe environment where applications can run in isolation without interfering with each other.<br>In short, it’s the bridge between <em>our code</em> and <em>the machine</em>.</p>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<h2 class="wp-block-heading"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/2699.png" alt="⚙" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Talking to the Kernel: System Calls</h2>



<p class="wp-block-paragraph">The communication happens through <strong>system calls (syscalls)</strong> — special functions that let user programs request services from the kernel.</p>



<p class="wp-block-paragraph">When a Go program executes something like:</p>



<pre class="wp-block-code"><code>f, _ := os.Open("data.txt")</code></pre>



<p class="wp-block-paragraph">this call travels through several layers:</p>



<ol class="wp-block-list">
<li>Go’s standard library (<code>os.Open</code>)</li>



<li>Go runtime → <code>syscall.Open</code></li>



<li>CPU executes the <code>syscall</code> instruction</li>



<li>The kernel runs <code>do_sys_openat2()</code> internally</li>



<li>A <strong>file descriptor</strong> (like <code>3</code>) is returned</li>
</ol>



<p class="wp-block-paragraph">Every I/O operation, process creation, or socket connection ultimately follows this same path — from Go, through the runtime, into the kernel.</p>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<h2 class="wp-block-heading"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f522.png" alt="🔢" class="wp-smiley" style="height: 1em; max-height: 1em;" /> File Descriptors: Numbers That Represent Everything</h2>



<p class="wp-block-paragraph">A <strong>file descriptor (FD)</strong> is a small integer the kernel uses to identify open resources.<br>In Unix, <em>everything is a file</em> — files, sockets, pipes, devices, and even event interfaces all share this abstraction.</p>



<p class="wp-block-paragraph">In Go, you can access the FD behind a file:</p>



<pre class="wp-block-code"><code>f, _ := os.Open("example.txt")
fmt.Println(f.Fd()) // e.g. 3
</code></pre>



<p class="wp-block-paragraph">The kernel manages this mapping so that user applications can safely access resources without touching hardware directly.</p>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<h2 class="wp-block-heading"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f9e9.png" alt="🧩" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Processes: The Kernel’s Living Entities</h2>



<p class="wp-block-paragraph">Every running program is represented in the kernel as a <strong>process</strong>.<br>It has its own memory, CPU state, and file descriptors — isolated from others.<br>In Go, we create new processes using the <code>os/exec</code> package:</p>



<pre class="wp-block-code"><code>cmd := exec.Command("sleep", "5")
cmd.Start()
</code></pre>



<p class="wp-block-paragraph">Behind the scenes, the kernel performs a <code>fork()</code> (clone current process) and <code>execve()</code> (replace it with a new program).<br>Each process gets a unique <strong>PID</strong>, managed by the kernel scheduler.</p>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<h2 class="wp-block-heading"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f310.png" alt="🌐" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Networking: Packets, Sockets, and the Kernel</h2>



<p class="wp-block-paragraph">All network communication passes through the kernel’s <strong>network stack</strong>.<br>When you run <code>net.Dial("tcp", "example.com:80")</code>, Go creates a socket, the kernel routes packets through the NIC driver, and responses flow back the same way.</p>



<p class="wp-block-paragraph">At a lower level, developers can open <strong>AF_PACKET sockets</strong> to capture raw Ethernet frames — the same technique used by tools like Wireshark or tcpdump.<br>With <code>AF_PACKET</code>, Go code can literally read the bytes that the NIC receives before the TCP/IP stack touches them.</p>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<h2 class="wp-block-heading"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f512.png" alt="🔒" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Security and Control: Syscall Firewalls and Isolation</h2>



<p class="wp-block-paragraph">Modern systems rely on the kernel not only for performance but also for <strong>security</strong>.<br>Mechanisms like <strong>seccomp</strong> act as syscall firewalls — filtering which system calls a process is allowed to make.<br>Containers combine <strong>namespaces</strong> (for isolation) and <strong>cgroups</strong> (for resource limits), allowing many isolated environments to share one kernel safely.</p>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<h2 class="wp-block-heading"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f9e0.png" alt="🧠" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Real-World Use Cases</h2>



<p class="wp-block-paragraph">Understanding kernel communication isn’t just theory — it’s the foundation of everything around us:</p>



<ul class="wp-block-list">
<li><strong>Monitoring tools</strong> like <code>htop</code>, <code>ps</code>, and Go-based agents read <code>/proc</code> and <code>/sys</code> for system data.</li>



<li><strong>Containers</strong> (Docker, Kubernetes) use kernel namespaces and cgroups to isolate workloads.</li>



<li><strong>Security tools</strong> apply seccomp filters or eBPF tracing to monitor system calls.</li>



<li><strong>Performance profiling</strong> tools hook into kernel events to analyze real-time system behavior.</li>



<li><strong>Network sniffers</strong> read raw packets via <code>AF_PACKET</code> or eBPF.</li>
</ul>



<p class="wp-block-paragraph">Every modern infrastructure layer, from observability to orchestration, depends on talking to the kernel.</p>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<h2 class="wp-block-heading"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f4ac.png" alt="💬" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Final Thoughts</h2>



<p class="wp-block-paragraph">The kernel may feel distant, but it’s part of every operation our programs perform.<br>By understanding how our Go code interacts with it — through syscalls, file descriptors, processes, and network sockets — we gain visibility and control over the system itself.</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p class="wp-block-paragraph">Every time your program runs, it’s already talking to the kernel —<br>you just have to learn to listen.</p>
</blockquote>
<p><a href="https://www.yakuter.com/talking-to-the-kernel-understanding-how-software-communicates-with-the-system/">Talking to the Kernel: Understanding How Software Communicates with the System</a> yazısı ilk önce <a href="https://www.yakuter.com">Yakuter</a> üzerinde ortaya çıktı.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.yakuter.com/talking-to-the-kernel-understanding-how-software-communicates-with-the-system/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Introducing the Go SDK for the Model Context Protocol (MCP)</title>
		<link>https://www.yakuter.com/introducing-the-go-sdk-for-the-model-context-protocol-mcp/</link>
					<comments>https://www.yakuter.com/introducing-the-go-sdk-for-the-model-context-protocol-mcp/#respond</comments>
		
		<dc:creator><![CDATA[Erhan Yakut]]></dc:creator>
		<pubDate>Sun, 28 Sep 2025 21:28:00 +0000</pubDate>
				<category><![CDATA[Genel]]></category>
		<guid isPermaLink="false">https://www.yakuter.com/?p=2704</guid>

					<description><![CDATA[<p>The open‐source ecosystem in Go just got a meaningful boost with the official Go SDK for the Model Context Protocol (MCP) – delivered via the repository go‑sdk under the organization ModelContextProtocol. As someone who lives and breathes Go and works at the crossroads of backend infrastructure and developer experience, I wanted to share a deeper [&#8230;]</p>
<p><a href="https://www.yakuter.com/introducing-the-go-sdk-for-the-model-context-protocol-mcp/">Introducing the Go SDK for the Model Context Protocol (MCP)</a> yazısı ilk önce <a href="https://www.yakuter.com">Yakuter</a> üzerinde ortaya çıktı.</p>
]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">The open‐source ecosystem in Go just got a meaningful boost with the official Go SDK for the Model Context Protocol (MCP) – delivered via the repository go‑sdk under the organization <a href="https://github.com/modelcontextprotocol/go-sdk"  target="_blank" rel="external nofollow"   class="wp-links-icon">ModelContextProtocol</a>. As someone who lives and breathes Go and works at the crossroads of backend infrastructure and developer experience, I wanted to share a deeper look at what this SDK brings, why it matters, and how you (yes you) might integrate it into your toolbelt.</p>



<span id="more-2704"></span>



<h2 class="wp-block-heading">Why this matters</h2>



<p class="wp-block-paragraph">The MCP specification is increasingly important in contexts where you need standardized tooling for systems that allow <em>models</em>, <em>contexts</em>, <em>tools</em> and <em>protocols</em> to interoperate. Having an <em>official</em>, well-maintained Go SDK means:</p>



<ul class="wp-block-list">
<li><strong>Language first-class support</strong>: Many Go backends, microservices and tooling systems lean on Go already. Having a dedicated SDK means fewer &#8220;make-it work&#8221; wrappers or sub-par third-party bindings.</li>



<li><strong>Better alignment with the spec</strong>: The repository states that &#8220;The SDK endeavours to implement the full MCP spec.&#8221; That means less guesswork for developers.</li>



<li><strong>Ecosystem credibility</strong>: The tag &#8220;official&#8221; and the collaboration with a major partner (Google) signals you’re not using an abandoned or half-baked project. </li>



<li><strong>Support for servers <em>and</em> clients</strong>: Whether you’re building the backend service providing tools/processes or you’re building the client that consumes them, this SDK handles both angles.</li>
</ul>



<p class="wp-block-paragraph">If you are working in Go and you’re building anything around model tooling, context propagation, or tool invocation protocols — this project is worth your attention.</p>



<h2 class="wp-block-heading">What the SDK gives you</h2>



<p class="wp-block-paragraph">From browsing the README and the repository structure, here are key features:</p>



<ol class="wp-block-list">
<li><strong>Importable packages</strong>
<ul class="wp-block-list">
<li><code>mcp</code> package: The primary API surface for constructing and using MCP clients and servers. </li>



<li><code>jsonrpc</code> package: Allows you to implement your own transports for MCP over custom channels.</li>



<li><code>auth</code> package: Offers primitives to support OAuth flows.</li>



<li><code>oauthex</code> package: Extends OAuth with features like Protected Resource Metadata.</li>
</ul>
</li>



<li><strong>Getting started simplicity</strong><br>The README includes a minimal server example (tool “greet” that says hi) using stdin/stdout as transport. This shows the SDK is designed to make it easy to <em>get going</em>.</li>



<li><strong>Full spec alignment</strong><br>With documentation under <code>docs/</code>, and examples in <code>examples/</code>, you have both conceptual guidance and sample code.</li>



<li><strong>MIT license, open to contributions</strong><br>This encourages enterprise adoption and community engagement without worrying about restrictive licensing.</li>
</ol>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<h2 class="wp-block-heading">Strengths (from a senior dev lens)</h2>



<ul class="wp-block-list">
<li><strong>Go idiomatic API</strong>: It doesn’t feel like a forced wrapper. If you know Go conventions (context.Context, error handling, interfaces), this SDK looks built for you.</li>



<li><strong>Modular architecture</strong>: Splitting concerns (core MCP logic, transport, auth) means your codebase can pick just what it needs and extend or replace other bits.</li>



<li><strong>Transport flexibility</strong>: The <code>jsonrpc</code> package and support for custom transports means you’re not locked into one mode of communication. Classic for building scalable microservice architectures.</li>



<li><strong>Spec clarity</strong>: Having the SDK tied closely to the spec means less drift over time and fewer surprises when integrating across different systems.</li>



<li><strong>Community + backing</strong>: The repository already shows significant stars, forks, contributors — which bodes well for longevity.</li>
</ul>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<h2 class="wp-block-heading">Where to watch / possible trade-offs</h2>



<p class="wp-block-paragraph">No project is without its caveats — let’s highlight what to watch:</p>



<ul class="wp-block-list">
<li><strong>Ecosystem maturity</strong>: While it’s official, depending on how long it’s been live and how many real-world users there are, you might encounter growing pains (bugs, missing edge-cases).</li>



<li><strong>Learning curve</strong>: If your team is new to MCP or to writing “tool + client” style services, there’ll be ramp-up. But that’s inherent to any protocol SDK.</li>



<li><strong>Transport/Deployment choices</strong>: The example uses stdin/stdout for tool invocation, which is great for certain contexts (CLI tools), but real-world server deployments may need HTTP, GRPC, etc. The SDK’s transport flexibility helps, but you’ll need to pick and maybe build some glue.</li>



<li><strong>Versioning and stability</strong>: As with any spec-aligned SDK, you’ll want to lock in version compatibility early and watch for breaking changes.</li>



<li><strong>Documentation gaps</strong>: Sometimes the best docs come after the initial release; be prepared to dive into code or examples.</li>
</ul>



<h2 class="wp-block-heading">How I&#8217;d use this in a real project</h2>



<p class="wp-block-paragraph">Let&#8217;s walk through a hypothetical: you&#8217;re building a platform that hosts “tools” (e.g., data-wranglers, model analyzers) and you need clients to invoke those tools securely, with context, results, and tracing. Here&#8217;s how you could leverage the SDK:</p>



<p class="wp-block-paragraph"><strong>Define your tool server</strong> </p>



<figure class="wp-block-embed is-type-rich is-provider-embed-handler wp-block-embed-embed-handler"><div class="wp-block-embed__wrapper">
View the code on <a href="https://gist.github.com/yakuter/eb420c6bb4f919d3cb81108f241b8d15"  target="_blank" rel="external nofollow"   class="wp-links-icon">Gist</a>.
</div></figure>



<p class="wp-block-paragraph"><strong>Build your client</strong> </p>



<figure class="wp-block-embed is-type-rich is-provider-embed-handler wp-block-embed-embed-handler"><div class="wp-block-embed__wrapper">
View the code on <a href="https://gist.github.com/yakuter/a48385c9704304bc181882a266b099e3"  target="_blank" rel="external nofollow"   class="wp-links-icon">Gist</a>.
</div></figure>



<ol class="wp-block-list">
<li><strong>Integrate OAuth / Authentication</strong><br>Use the <code>auth</code> package to let clients authenticate and authorize tool calls. This makes sense when you host your “tool network” in a multi-tenant environment.</li>



<li><strong>Transport adaptation</strong><br>In production you likely won&#8217;t use stdin/stdout; you might wrap HTTP or WebSockets. The SDK&#8217;s <code>jsonrpc</code> package helps — you just build a transport that satisfies the interface.</li>



<li><strong>Monitoring &amp; Context Propagation</strong><br>Because MCP is about &#8220;context&#8221; (metadata, tool invocation context, tracing), you&#8217;d tie logging, tracing (e.g., OpenTelemetry), metadata propagation around those tool calls.</li>
</ol>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<h2 class="wp-block-heading">Final thoughts</h2>



<p class="wp-block-paragraph">In short: if you&#8217;re working in Go, and especially if you operate a system where <em>tools</em>, <em>models</em>, <em>clients</em>, and <em>servers</em> need to speak a common protocol with good ergonomics, this SDK is <strong>definitely worth adopting</strong>.</p>



<p class="wp-block-paragraph">It&#8217;s not just another wrapper — the &#8220;official&#8221; branding, spec alignment, modular architecture, and Go-native design all give it a strong foundation. As with any such SDK, you’ll want to evaluate how it fits your architecture (transport selection, auth model, tooling deployment) but once aligned, it can significantly reduce the engineering overhead around protocol plumbing.</p>



<p class="wp-block-paragraph">If I were advising my team, I&#8217;d say: &#8220;Let&#8217;s prototype using this SDK. If it meets our throughput and deployment needs, then adopt it for our next generation of services.&#8221;</p>
<p><a href="https://www.yakuter.com/introducing-the-go-sdk-for-the-model-context-protocol-mcp/">Introducing the Go SDK for the Model Context Protocol (MCP)</a> yazısı ilk önce <a href="https://www.yakuter.com">Yakuter</a> üzerinde ortaya çıktı.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.yakuter.com/introducing-the-go-sdk-for-the-model-context-protocol-mcp/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Iterate, Slice, and Deduplicate: Go’s New Tools for Cleaner Code</title>
		<link>https://www.yakuter.com/iterate-slice-and-deduplicate-gos-new-tools-for-cleaner-code/</link>
					<comments>https://www.yakuter.com/iterate-slice-and-deduplicate-gos-new-tools-for-cleaner-code/#respond</comments>
		
		<dc:creator><![CDATA[Erhan Yakut]]></dc:creator>
		<pubDate>Thu, 17 Jul 2025 15:27:00 +0000</pubDate>
				<category><![CDATA[Golang]]></category>
		<guid isPermaLink="false">https://www.yakuter.com/?p=2706</guid>

					<description><![CDATA[<p>Go keeps evolving — not through radical changes, but through small, elegant additions that make everyday programming smoother. Three of the newest additions to the standard library — iter, slices, and unique — are perfect examples of this evolution. Together, they bring safer, more expressive, and more composable ways to work with data, making Go [&#8230;]</p>
<p><a href="https://www.yakuter.com/iterate-slice-and-deduplicate-gos-new-tools-for-cleaner-code/">Iterate, Slice, and Deduplicate: Go’s New Tools for Cleaner Code</a> yazısı ilk önce <a href="https://www.yakuter.com">Yakuter</a> üzerinde ortaya çıktı.</p>
]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">Go keeps evolving — not through radical changes, but through small, elegant additions that make everyday programming smoother. Three of the newest additions to the standard library — <code>iter</code>, <code>slices</code>, and <code>unique</code> — are perfect examples of this evolution. Together, they bring safer, more expressive, and more composable ways to work with data, making Go code both simpler and more powerful.</p>



<span id="more-2706"></span>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<h2 class="wp-block-heading">The <code>iter</code> Package — Functional Iteration, Go Style</h2>



<p class="wp-block-paragraph">For years, Go developers relied on slices, channels, or custom closures for iteration. The <code>iter</code> package formalizes that pattern — introducing typed iterator functions that integrate seamlessly with Go’s <code>for … range</code> syntax.</p>



<pre class="wp-block-code"><code>
func Numbers() iter.Seq&#91;int] {
    return func(yield func(int) bool) {
        for i := 0; i &lt; 3; i++ {
            if !yield(i) {
                return
            }
        }
    }
}

for n := range Numbers() {
    fmt.Println(n)
}
</code></pre>



<p class="wp-block-paragraph"><strong>Why it matters:</strong></p>



<ul class="wp-block-list">
<li>Enables lazy, composable iteration (no need to build full slices in memory).</li>



<li>Works naturally with <code>range</code>.</li>



<li>Provides a new foundation for streaming or pipeline-like APIs in Go.</li>
</ul>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<h2 class="wp-block-heading">The <code>slices</code> Package — Safe, Generic Utilities for Everyday Work</h2>



<p class="wp-block-paragraph">Every Go developer has written some variation of “find,” “sort,” or “delete from slice.” Now, these operations are part of the language’s toolkit — type-safe, generic, and built right in.</p>



<pre class="wp-block-code"><code>
import "slices"

nums := &#91;]int{3, 1, 2}
slices.Sort(nums)
fmt.Println(nums) // &#91;1 2 3]

if slices.Contains(nums, 2) {
    fmt.Println("Found 2!")
}

copy := slices.Clone(nums)
</code></pre>



<p class="wp-block-paragraph"><strong>Highlights:</strong></p>



<ul class="wp-block-list">
<li><code>Sort</code>, <code>Contains</code>, <code>Insert</code>, <code>Delete</code>, and <code>Clone</code> — all type-safe.</li>



<li>Cleaner syntax than <code>sort.Slice</code> or manual loops.</li>



<li>No external dependencies like <code>x/exp/slices</code>.</li>
</ul>



<p class="wp-block-paragraph"><strong>Why it matters:</strong> Fewer bugs, less boilerplate, and a standard way to handle the most common operations on slices.</p>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<h2 class="wp-block-heading">The <code>unique</code> Package — Deduplication Made Simple</h2>



<p class="wp-block-paragraph">Go now includes a lightweight utility for deduplicating sorted slices — a deceptively small feature that simplifies many real-world workflows.</p>



<pre class="wp-block-code"><code>
import (
    "slices"
    "unique"
    "fmt"
)

names := &#91;]string{"bob", "bob", "alice", "carol", "carol"}
slices.Sort(names)
n := unique.Strings(names)
fmt.Println(names&#91;:n]) // &#91;alice bob carol]
</code></pre>



<p class="wp-block-paragraph"><strong>How it works:</strong></p>



<ul class="wp-block-list">
<li>Removes duplicates <em>in place</em> (no extra allocation).</li>



<li>Returns the index up to which the elements are unique.</li>



<li>Supports multiple types (<code>Ints</code>, <code>Strings</code>, etc.).</li>
</ul>



<p class="wp-block-paragraph"><strong>Why it matters:</strong> Great for cleaning datasets, logs, or identifiers — without hand-written deduplication loops.</p>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<h2 class="wp-block-heading">Composing Them Together</h2>



<p class="wp-block-paragraph">These new tools are designed to compose beautifully:</p>



<pre class="wp-block-code"><code>
seq := func(yield func(int) bool) {
    for i := 0; i &lt; 10; i++ {
        yield(i % 3)
    }
}

nums := slices.Collect(seq)
slices.Sort(nums)
n := unique.Ints(nums)
fmt.Println(nums&#91;:n]) // &#91;0 1 2]
</code></pre>



<p class="wp-block-paragraph">Here, we:</p>



<ol class="wp-block-list">
<li>Generate numbers lazily with an iterator.</li>



<li>Collect them into a slice.</li>



<li>Sort and deduplicate — all with pure standard library code.</li>
</ol>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<h2 class="wp-block-heading"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/270d.png" alt="✍" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Final Thoughts</h2>



<p class="wp-block-paragraph">The addition of <code>iter</code>, <code>slices</code>, and <code>unique</code> doesn’t reinvent Go — it refines it. They make iteration more expressive, collections safer, and data handling cleaner, all while staying true to Go’s philosophy of simplicity and clarity.</p>



<p class="wp-block-paragraph">If you write Go regularly, take a weekend to refactor some loops with <code>iter.Seq</code> and replace your helper utilities with <code>slices</code> and <code>unique</code>. You’ll end up with code that’s more idiomatic, maintainable, and simply <em>Go-ier</em>.</p>
<p><a href="https://www.yakuter.com/iterate-slice-and-deduplicate-gos-new-tools-for-cleaner-code/">Iterate, Slice, and Deduplicate: Go’s New Tools for Cleaner Code</a> yazısı ilk önce <a href="https://www.yakuter.com">Yakuter</a> üzerinde ortaya çıktı.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.yakuter.com/iterate-slice-and-deduplicate-gos-new-tools-for-cleaner-code/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Retrieving the Correct Hostname on macOS</title>
		<link>https://www.yakuter.com/retrieving-the-correct-hostname-on-macos/</link>
					<comments>https://www.yakuter.com/retrieving-the-correct-hostname-on-macos/#respond</comments>
		
		<dc:creator><![CDATA[Erhan Yakut]]></dc:creator>
		<pubDate>Tue, 18 Feb 2025 21:13:37 +0000</pubDate>
				<category><![CDATA[Golang]]></category>
		<guid isPermaLink="false">https://www.yakuter.com/?p=2697</guid>

					<description><![CDATA[<p>When dealing with macOS systems, retrieving the correct hostname can be tricky, especially in environments where DHCP and reverse lookup mechanisms are in play. Many tools rely on the hostname command, which can return unreliable results if the system hostname is not explicitly set. This often leads to incorrect asset tracking and duplicate entries in [&#8230;]</p>
<p><a href="https://www.yakuter.com/retrieving-the-correct-hostname-on-macos/">Retrieving the Correct Hostname on macOS</a> yazısı ilk önce <a href="https://www.yakuter.com">Yakuter</a> üzerinde ortaya çıktı.</p>
]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">When dealing with macOS systems, retrieving the correct hostname can be tricky, especially in environments where DHCP and reverse lookup mechanisms are in play. Many tools rely on the <code>hostname</code> command, which can return unreliable results if the system hostname is not explicitly set. This often leads to incorrect asset tracking and duplicate entries in IT asset management systems.</p>



<p class="wp-block-paragraph">In this article, we will explore different ways to correctly retrieve a Mac&#8217;s hostname, covering three key identifiers available through the <code>scutil</code> command. </p>



<span id="more-2697"></span>



<h2 class="wp-block-heading">Understanding macOS Hostname Types</h2>



<p class="wp-block-paragraph">macOS defines hostnames in three different contexts:</p>



<ol start="1" class="wp-block-list">
<li><strong>ComputerName</strong> – The user-friendly name displayed in System Preferences and used for AirDrop, sharing, and local identification.</li>



<li><strong>LocalHostName</strong> – The name used for Bonjour networking, often seen in network browsing applications.</li>



<li><strong>HostName</strong> – The traditional DNS hostname, which may not always be set on macOS by default.</li>
</ol>



<h3 class="wp-block-heading">Checking Hostnames Using <code>scutil</code></h3>



<p class="wp-block-paragraph">The <code>scutil</code> command provides a reliable way to retrieve these names:</p>



<pre class="wp-block-code"><code>scutil --get ComputerName
Output: Erhan's MacBook Pro</code></pre>



<pre class="wp-block-code"><code>scutil --get LocalHostName
Output: Erhans-MacBook-Pro</code></pre>



<pre class="wp-block-code"><code>scutil --get HostName
Output: HostName: not set</code></pre>



<h3 class="wp-block-heading">Problem</h3>



<p class="wp-block-paragraph"><strong>If the HostName is unset, macOS attempts to resolve it dynamically</strong>, leading to potential mismatches in environments with DHCP and reverse DNS lookups.</p>



<h3 class="wp-block-heading">Effects of an Unset HostName</h3>



<p class="wp-block-paragraph">When the <code>hostname</code> command is executed and the HostName is not explicitly set, macOS may attempt to resolve the hostname using DHCP-assigned values or reverse DNS lookups. This can lead to:</p>



<ul class="wp-block-list">
<li>Hostname mismatches between different management tools.</li>



<li>Duplicate asset entries in IT asset tracking systems.</li>



<li>Incorrect association of devices with previously assigned IP addresses.</li>
</ul>



<p class="wp-block-paragraph">Here’s an example of what happens when <code>hostname</code> is executed on a system where HostName is unset:</p>



<pre class="wp-block-code"><code>hostname
Output: random-dhcp-name.local</code></pre>



<p class="wp-block-paragraph">Similarly, performing an <code>nslookup</code> can return unexpected results:</p>



<pre class="wp-block-code"><code>nslookup 192.168.1.10
Output: Name: windows-pc-old.local</code></pre>



<p class="wp-block-paragraph">This can cause confusion when tracking assets since the Mac may be incorrectly labeled as a previously assigned Windows workstation.</p>



<h2 class="wp-block-heading">Ensuring Consistent Hostname Resolution</h2>



<p class="wp-block-paragraph">To ensure a consistent hostname across different applications and IT management tools, explicitly set the HostName using:</p>



<pre class="wp-block-code"><code>sudo scutil --set HostName "Erhans-MacBook-Pro"</code></pre>



<p class="wp-block-paragraph">Verify the change:</p>



<pre class="wp-block-code"><code>scutil --get HostName</code></pre>



<p class="wp-block-paragraph">Output:</p>



<pre class="wp-block-code"><code>Erhans-MacBook-Pro</code></pre>



<h3 class="wp-block-heading">Best Practices for macOS Hostname Management</h3>



<ol start="1" class="wp-block-list">
<li><strong>Use </strong><code><strong>scutil --get ComputerName</strong></code><strong> for user-friendly identification.</strong></li>



<li><strong>Use </strong><code><strong>scutil --get LocalHostName</strong></code><strong> for Bonjour network discovery.</strong></li>



<li><strong>Explicitly set </strong><code><strong>HostName</strong></code><strong> using </strong><code><strong>scutil --set HostName</strong></code><strong> to avoid DHCP-related inconsistencies.</strong></li>



<li><strong>Verify hostname settings after network changes or system updates.</strong></li>
</ol>



<p class="wp-block-paragraph">By following these best practices, IT administrators can ensure accurate tracking and management of Mac devices in mixed network environments.</p>
<p><a href="https://www.yakuter.com/retrieving-the-correct-hostname-on-macos/">Retrieving the Correct Hostname on macOS</a> yazısı ilk önce <a href="https://www.yakuter.com">Yakuter</a> üzerinde ortaya çıktı.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.yakuter.com/retrieving-the-correct-hostname-on-macos/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>go-mage: Simplify Your Go Project Builds with Magefile</title>
		<link>https://www.yakuter.com/go-mage-simplify-your-go-project-builds-with-magefile/</link>
					<comments>https://www.yakuter.com/go-mage-simplify-your-go-project-builds-with-magefile/#respond</comments>
		
		<dc:creator><![CDATA[Erhan Yakut]]></dc:creator>
		<pubDate>Tue, 10 Dec 2024 08:55:45 +0000</pubDate>
				<category><![CDATA[Genel]]></category>
		<guid isPermaLink="false">https://www.yakuter.com/?p=2690</guid>

					<description><![CDATA[<p>Managing builds for Go projects can sometimes feel cumbersome, especially when dealing with cross-platform requirements or complex configurations. That&#8217;s where go-mage comes in-a project designed to replace traditional Makefiles with the power and flexibility of Magefile. In this post, we’ll explore what go-mage is, why it’s valuable, and how you can get started with it [&#8230;]</p>
<p><a href="https://www.yakuter.com/go-mage-simplify-your-go-project-builds-with-magefile/">go-mage: Simplify Your Go Project Builds with Magefile</a> yazısı ilk önce <a href="https://www.yakuter.com">Yakuter</a> üzerinde ortaya çıktı.</p>
]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">Managing builds for Go projects can sometimes feel cumbersome, especially when dealing with cross-platform requirements or complex configurations. That&#8217;s where <strong><a href="https://github.com/yakuter/go-mage"  target="_blank" rel="external nofollow"   class="wp-links-icon">go-mage</a></strong> comes in-a project designed to replace traditional <strong>Makefiles</strong> with the power and flexibility of <a href="https://github.com/magefile/mage"  target="_blank" rel="external nofollow"   class="wp-links-icon">Magefile</a>.</p>



<p class="wp-block-paragraph">In this post, we’ll explore what go-mage is, why it’s valuable, and how you can get started with it to simplify your Go project workflows.</p>



<span id="more-2690"></span>



<h2 class="wp-block-heading">Why go-mage?</h2>



<p class="wp-block-paragraph"><strong>go-mage</strong> leverages <a href="https://github.com/magefile/mage"  target="_blank" rel="external nofollow"   class="wp-links-icon">Magefile</a>, a build tool written in Go, to manage and build Go projects. Unlike traditional Makefiles, Magefile is written in Go itself, making it:</p>



<ul class="wp-block-list">
<li>More familiar for Go developers.</li>



<li>Easier to customize using Go&#8217;s powerful syntax and tooling.</li>



<li>Cross-platform by design, working seamlessly across Windows, macOS, and Linux.</li>
</ul>



<h2 class="wp-block-heading">Features of go-mage</h2>



<p class="wp-block-paragraph"><strong>go-mage</strong> offers a robust set of features to streamline your build and development process:</p>



<h3 class="wp-block-heading">1. <strong>Cross-Platform Support</strong></h3>



<ul class="wp-block-list">
<li>Build projects on Windows, macOS, and Linux with ease.</li>



<li>Customize builds for specific operating systems using environment variables (e.g., <code>MACOS_SDK_VERSION=15.0</code> for macOS).</li>
</ul>



<h3 class="wp-block-heading">2. <strong>Windows-Specific Optimizations</strong></h3>



<ul class="wp-block-list">
<li>Automatically generates <code>.syso</code> and version info files during the build process.</li>



<li>Supports MSYS MinGW for Windows builds.</li>



<li>Reminder: Place your <code>app.manifest</code> and <code>app.icon</code> files in the <code>build/windows/assets</code> directory before building for Windows.</li>
</ul>



<h3 class="wp-block-heading">3. <strong>Security and Code Quality Tools</strong></h3>



<ul class="wp-block-list">
<li>Automatically runs security scans using <code>govulncheck</code>.</li>



<li>Enforces code quality standards with <code>golangci-lint</code>.</li>



<li>Generates test coverage reports with <code>gocov</code>.</li>
</ul>



<h3 class="wp-block-heading">4. <strong>Version Control Integration</strong></h3>



<p class="wp-block-paragraph">During the build process, <code>Version</code>, <code>BuildTime</code>, <code>CommitID</code>, and <code>BuildMode</code> variables are dynamically updated, providing detailed metadata for every build.</p>



<h2 class="wp-block-heading">Getting Started with go-mage</h2>



<p class="wp-block-paragraph">Setting up <strong>go-mage</strong> is straightforward. Here’s how you can start using it in your Go projects:</p>



<h3 class="wp-block-heading">Step 1: Install Mage</h3>



<p class="wp-block-paragraph"><code>magefile</code> is the core of go-mage, so ensure you have Mage installed:</p>



<pre class="wp-block-preformatted"><code>go install github.com/magefile/mage@latest</code></pre>



<p class="wp-block-paragraph">Alternatively, you can run the <code>magefile</code> directly with Go:</p>



<pre class="wp-block-preformatted">bashCopy code<code>go run mage.go build</code></pre>



<h3 class="wp-block-heading">Step 2: Clone the Repository</h3>



<p class="wp-block-paragraph">Clone the <strong>go-mage</strong> repository and install dependencies:</p>



<pre class="wp-block-preformatted">bashCopy code<code>git clone https://github.com/yakuter/go-mage.git<br>cd go-mage<br>go mod tidy</code></pre>



<h3 class="wp-block-heading">Step 3: Explore Mage Targets</h3>



<p class="wp-block-paragraph">Run <code>mage</code> in the project directory to see available targets:</p>



<pre class="wp-block-preformatted"><code>mage</code></pre>



<p class="wp-block-paragraph">You’ll see options like:</p>



<pre class="wp-block-preformatted"><code>Targets:<br>  build        builds the binary.<br>  clean        cleans the build directory.<br>  generate     runs go generate.<br>  linter       runs the linter.<br>  test         runs the tests.<br>  vulncheck    runs the vulnerability check.</code></pre>



<h2 class="wp-block-heading">Example: Building and Testing with go-mage</h2>



<p class="wp-block-paragraph">To build the project:</p>



<pre class="wp-block-preformatted"><code>mage build</code></pre>



<p class="wp-block-paragraph">To check for vulnerabilities:</p>



<pre class="wp-block-preformatted"><code>mage vulncheck</code></pre>



<p class="wp-block-paragraph">To clean the build directory:</p>



<pre class="wp-block-preformatted"><code>mage clean</code></pre>



<h2 class="wp-block-heading">Why Choose go-mage for Your Projects?</h2>



<p class="wp-block-paragraph">By adopting <strong>go-mage</strong>, you gain:</p>



<ol class="wp-block-list">
<li><strong>Flexibility</strong>: Harness the power of Go for build scripting, reducing dependency on external tools.</li>



<li><strong>Cross-Platform Efficiency</strong>: Build effortlessly on multiple operating systems.</li>



<li><strong>Improved Tooling</strong>: Automate code quality checks, security scans, and metadata injection during the build process.</li>
</ol>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<h2 class="wp-block-heading">Contribute to go-mage</h2>



<p class="wp-block-paragraph"><strong>go-mage</strong> is an open-source project, and contributions are always welcome. If you’d like to get involved, feel free to:</p>



<ul class="wp-block-list">
<li>Submit a pull request.</li>



<li>Open an issue to suggest improvements or report bugs.</li>
</ul>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<h2 class="wp-block-heading">Conclusion</h2>



<p class="wp-block-paragraph"><strong>go-mage</strong> is more than just a build tool—it’s a step toward making Go project development simpler, faster, and more maintainable. Whether you&#8217;re building for Windows, macOS, or Linux, go-mage provides the tools and structure you need to succeed.</p>



<p class="wp-block-paragraph">Ready to give it a try? <a href="https://github.com/yakuter/go-mage.git"  target="_blank" rel="external nofollow"   class="wp-links-icon">Clone the repository</a> and start building smarter today!</p>
<p><a href="https://www.yakuter.com/go-mage-simplify-your-go-project-builds-with-magefile/">go-mage: Simplify Your Go Project Builds with Magefile</a> yazısı ilk önce <a href="https://www.yakuter.com">Yakuter</a> üzerinde ortaya çıktı.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.yakuter.com/go-mage-simplify-your-go-project-builds-with-magefile/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Testing Exit, Fatal, and Panic Scenarios in Go</title>
		<link>https://www.yakuter.com/testing-exit-fatal-and-panic-scenarios-in-go/</link>
					<comments>https://www.yakuter.com/testing-exit-fatal-and-panic-scenarios-in-go/#respond</comments>
		
		<dc:creator><![CDATA[Erhan Yakut]]></dc:creator>
		<pubDate>Mon, 22 Jul 2024 11:07:01 +0000</pubDate>
				<category><![CDATA[Golang]]></category>
		<guid isPermaLink="false">https://www.yakuter.com/?p=2688</guid>

					<description><![CDATA[<p>In Go applications, handling critical errors often involves terminating the program using os.Exit, logging fatal messages, or triggering a panic. Testing such scenarios can be tricky because they interrupt the normal flow of execution. However, with the right techniques, you can capture and verify their behavior effectively. This post builds upon the concept of using [&#8230;]</p>
<p><a href="https://www.yakuter.com/testing-exit-fatal-and-panic-scenarios-in-go/">Testing Exit, Fatal, and Panic Scenarios in Go</a> yazısı ilk önce <a href="https://www.yakuter.com">Yakuter</a> üzerinde ortaya çıktı.</p>
]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">In Go applications, handling critical errors often involves terminating the program using <code>os.Exit</code>, logging fatal messages, or triggering a <code>panic</code>. Testing such scenarios can be tricky because they interrupt the normal flow of execution. However, with the right techniques, you can capture and verify their behavior effectively. This post builds upon the concept of using stdout in tests and explores how to handle exit, fatal, and panic scenarios.</p>



<h3 class="wp-block-heading">Why Test Exit, Fatal, and Panic Scenarios?</h3>



<p class="wp-block-paragraph">Testing these critical scenarios ensures:</p>



<ol start="1" class="wp-block-list">
<li><strong>Error Handling:</strong> The application responds as expected to severe errors.</li>



<li><strong>Message Validation:</strong> Correct error messages or logs are generated for debugging or user feedback.</li>



<li><strong>Program Stability:</strong> Edge cases and exceptional conditions are properly managed without unintended consequences.</li>
</ol>



<h3 class="wp-block-heading">Capturing <code>os.Exit</code> Calls</h3>



<p class="wp-block-paragraph">When a program calls <code>os.Exit</code>, it terminates immediately. To test functions that call <code>os.Exit</code>, you can mock this behavior using a custom implementation.</p>



<script src="https://gist.github.com/yakuter/8bc267237300c6dafdcdce3ca0ae7f22.js"></script>



<h3 class="wp-block-heading">Testing <code>log.Fatal</code></h3>



<p class="wp-block-paragraph"><code>log.Fatal</code> logs a message to stderr and calls <code>os.Exit(1)</code>. The testing strategy is similar to capturing <code>os.Exit</code> but includes verifying the log output.</p>



<script src="https://gist.github.com/yakuter/04b9466626c2fd1eec074157856e57d3.js"></script>



<h3 class="wp-block-heading">Testing Panic Scenarios</h3>



<p class="wp-block-paragraph">When a <code>panic</code> is triggered, the program halts unless it is recovered. To test <code>panic</code> scenarios, you can use the <code>recover</code> function.</p>



<script src="https://gist.github.com/yakuter/cf920900ff307bb53f4a28b868b0252e.js"></script>



<h3 class="wp-block-heading">Key Considerations</h3>



<ul class="wp-block-list">
<li><strong>Isolation:</strong> Mocking <code>os.Exit</code> or capturing logs should not interfere with other tests. Use deferred functions to restore state.</li>



<li><strong>Parallelism:</strong> Avoid shared global state when tests run in parallel.</li>



<li><strong>Error Messages:</strong> Ensure error messages are informative and consistent.</li>
</ul>



<h3 class="wp-block-heading">Conclusion</h3>



<p class="wp-block-paragraph">Testing critical failure scenarios like <code>os.Exit</code>, <code>log.Fatal</code>, and <code>panic</code> ensures your application handles errors predictably and provides helpful feedback. By capturing stdout and stderr, mocking behaviors, and using <code>recover</code>, you can write comprehensive tests that improve code quality and reliability.</p>
<p><a href="https://www.yakuter.com/testing-exit-fatal-and-panic-scenarios-in-go/">Testing Exit, Fatal, and Panic Scenarios in Go</a> yazısı ilk önce <a href="https://www.yakuter.com">Yakuter</a> üzerinde ortaya çıktı.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.yakuter.com/testing-exit-fatal-and-panic-scenarios-in-go/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>How to Use Stdout in Go Tests</title>
		<link>https://www.yakuter.com/how-to-use-stdout-in-go-tests/</link>
					<comments>https://www.yakuter.com/how-to-use-stdout-in-go-tests/#respond</comments>
		
		<dc:creator><![CDATA[Erhan Yakut]]></dc:creator>
		<pubDate>Fri, 05 Jul 2024 07:06:13 +0000</pubDate>
				<category><![CDATA[Golang]]></category>
		<guid isPermaLink="false">https://www.yakuter.com/?p=2683</guid>

					<description><![CDATA[<p>Stdout, short for standard output, is a stream where a program writes its output data. In most cases, this data is displayed in the console or terminal. It is one of the primary communication channels in command-line applications and scripts, enabling users to see results, logs, or messages generated by the program. Understanding how to [&#8230;]</p>
<p><a href="https://www.yakuter.com/how-to-use-stdout-in-go-tests/">How to Use Stdout in Go Tests</a> yazısı ilk önce <a href="https://www.yakuter.com">Yakuter</a> üzerinde ortaya çıktı.</p>
]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">Stdout, short for standard output, is a stream where a program writes its output data. In most cases, this data is displayed in the console or terminal. It is one of the primary communication channels in command-line applications and scripts, enabling users to see results, logs, or messages generated by the program. Understanding how to work with stdout is essential for debugging and testing purposes.</p>



<p class="wp-block-paragraph">Writing tests is a critical part of software development. In Go, the standard library provides a very capable <code>testing</code> package. Sometimes, however, you may need to test the output written to the standard output (stdout). For example, you might want to capture and verify the console output of a function. In this post, we will explore how to use stdout effectively in Go tests.</p>



<h3 class="wp-block-heading">Why Capturing Stdout Matters</h3>



<p class="wp-block-paragraph">Capturing stdout in tests is important in scenarios like:</p>



<ol start="1" class="wp-block-list">
<li><strong>Validating Logs or Console Messages:</strong> You want to ensure a program outputs the correct messages under specific conditions.</li>



<li><strong>Testing CLI Applications:</strong> Command-line applications often rely on stdout for their outputs.</li>



<li><strong>Analyzing Side Effects:</strong> Verifying the output written by functions helps in testing side effects.</li>
</ol>



<h3 class="wp-block-heading">Redirecting and Capturing Stdout with <code>os</code> and <code>io</code> Packages</h3>



<p class="wp-block-paragraph">In Go, you can use the <code>os</code> and <code>io</code> packages to capture stdout by redirecting it. Here’s an example:</p>



<script src="https://gist.github.com/yakuter/6556d918ecf0839aa809a3ef628cf53f.js"></script>



<h3 class="wp-block-heading">How It Works</h3>



<ol start="1" class="wp-block-list">
<li><strong>Backup </strong><code><strong>os.Stdout</strong></code><strong>:</strong> To avoid losing the original stdout, store it in a variable.</li>



<li><strong>Use </strong><code><strong>os.Pipe</strong></code><strong>:</strong> Create a new read-write pipe using <code>os.Pipe</code>.</li>



<li><strong>Redirect </strong><code><strong>os.Stdout</strong></code><strong>:</strong> Set <code>os.Stdout</code> to the write end of the pipe.</li>



<li><strong>Capture Output:</strong> Run the code to be tested and capture the output from the read end of the pipe.</li>



<li><strong>Restore and Validate:</strong> Restore the original stdout and verify the captured output.</li>
</ol>



<h3 class="wp-block-heading">Things to Keep in Mind</h3>



<ul class="wp-block-list">
<li><strong>Performance:</strong> Redirecting stdout can add some overhead. Use it only when necessary.</li>



<li><strong>Concurrency:</strong> If tests run in parallel, redirecting stdout can interfere with other tests. Consider running such tests serially or using alternative methods.</li>



<li><strong>Mocking:</strong> In complex scenarios, consider mocking stdout instead of redirecting it.</li>
</ul>



<h3 class="wp-block-heading">Conclusion</h3>



<p class="wp-block-paragraph">Capturing stdout in Go is a useful technique for testing CLI applications or verifying console outputs. With <code>os</code> and <code>io</code> packages, you can implement this functionality efficiently. By carefully planning and incorporating this method into your test strategy, you can improve the quality and reliability of your tests.</p>
<p><a href="https://www.yakuter.com/how-to-use-stdout-in-go-tests/">How to Use Stdout in Go Tests</a> yazısı ilk önce <a href="https://www.yakuter.com">Yakuter</a> üzerinde ortaya çıktı.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.yakuter.com/how-to-use-stdout-in-go-tests/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Go ile Veri Kopyalama ve Taşıma Teknikleri</title>
		<link>https://www.yakuter.com/go-ile-veri-kopyalama-ve-tasima-teknikleri/</link>
					<comments>https://www.yakuter.com/go-ile-veri-kopyalama-ve-tasima-teknikleri/#respond</comments>
		
		<dc:creator><![CDATA[Erhan Yakut]]></dc:creator>
		<pubDate>Wed, 14 Feb 2024 10:22:47 +0000</pubDate>
				<category><![CDATA[Golang]]></category>
		<guid isPermaLink="false">https://www.yakuter.com/?p=2657</guid>

					<description><![CDATA[<p>Go programlama dili, modern yazılım geliştirme pratiklerini destekleyen etkileyici özelliklere sahip olmasıyla bilinir. Google tarafından 2009 yılında tanıtılan bu dil, özellikle eşzamanlılık (concurrency) ve sistem programlaması gibi alanlarda ön plana çıkar. Gömülü sistemlerden büyük ölçekli dağıtık sistemlere kadar geniş bir yelpazede kullanılan Go, veri kopyalama ve taşıma teknikleri açısından da geliştiricilere güçlü araçlar sunar. Bu [&#8230;]</p>
<p><a href="https://www.yakuter.com/go-ile-veri-kopyalama-ve-tasima-teknikleri/">Go ile Veri Kopyalama ve Taşıma Teknikleri</a> yazısı ilk önce <a href="https://www.yakuter.com">Yakuter</a> üzerinde ortaya çıktı.</p>
]]></description>
										<content:encoded><![CDATA[<p>Go programlama dili, modern yazılım geliştirme pratiklerini destekleyen etkileyici özelliklere sahip olmasıyla bilinir. Google tarafından 2009 yılında tanıtılan bu dil, özellikle eşzamanlılık (concurrency) ve sistem programlaması gibi alanlarda ön plana çıkar. Gömülü sistemlerden büyük ölçekli dağıtık sistemlere kadar geniş bir yelpazede kullanılan Go, veri kopyalama ve taşıma teknikleri açısından da geliştiricilere güçlü araçlar sunar. Bu makalede, Go&#8217;nun veri kopyalama ve taşıma teknikleri ile bu tekniklerin kullanımlarını ve püf noktalarını ele alacağız. Bu kapsamlı rehber, hem yeni başlayanlar için temel bir giriş sağlarken hem de deneyimli geliştiricilere derinlemesine bilgiler sunacak. Go ile veri yönetiminin inceliklerini keşfederken, dilin sağladığı avantajları maksimize etmenin yollarını öğreneceksiniz.</p>
<p><span id="more-2657"></span></p>
<h2>copy Fonksiyonunun Kullanımı</h2>
<p>Go programlama dilinde, <a href="https://pkg.go.dev/builtin#copy"  target="_blank" rel="external nofollow"   class="wp-links-icon"><code>copy</code></a> fonksiyonu dilin yerleşik (builtin) fonksiyonlarından biridir ve özellikle slice&#8217;lar arası veri kopyalama işlemlerinde sıklıkla kullanılır. Bu fonksiyon, kaynak slice&#8217;tan hedef slice&#8217;a veri kopyalamak için tasarlanmıştır ve kullanımı son derece basittir ancak dikkat edilmesi gereken birkaç nokta vardır.</p>
<ol>
<li>Bir slice&#8217;ı diğerine kopyalarken, <strong>kopyalama işlemi hedef slice&#8217;ın kapasitesine bağlıdır.</strong> Eğer hedef yeterli büyükte değilse, slice&#8217;ın tamamı kopyalanamayabilir.</li>
<li><code>copy</code> fonksiyonu, kopyalanan eleman sayısını döndürür, bu da işlemin başarılı olup olmadığını kontrol etmek için kullanılabilir.</li>
<li>İlk parametre hedef (destination), ikinci parametre kaynak (source)&#8217;tır. <code>copy(dst, src)</code></li>
<li><code>copy</code> fonksiyonu, slice pointer&#8217;ları arasında değil, slice&#8217;ların temsil ettiği değerler (elemanlar) arasında kopyalama işlemi gerçekleştirir. Bu, iki slice&#8217;ın da aynı underlying array&#8217;i paylaşmadığı anlamına gelir; yani <code>copy</code> işlemi sonrası, kaynak slice&#8217;daki değişiklikler hedef slice&#8217;ı etkilemez!</li>
</ol>
<p><script src="https://gist.github.com/yakuter/b93569aa8060829a3ff44f27c9edeb7a.js"></script></p>
<h2>append Fonksiyonunun Kullanımı</h2>
<p>Go programlama dilinde, <code>append</code> fonksiyonu, slice&#8217;lara dinamik olarak eleman eklemek için kullanılan yerleşik bir fonksiyondur ve şunlara dikkat etmek gerekir:</p>
<ol>
<li><code>append</code> ile, bir slice&#8217;ın kapasitesi otomatik olarak yönetilir; eğer slice&#8217;ın mevcut kapasitesi eklenmek istenen yeni elemanları alacak kadar büyük değilse, Go dilinin çalışma zamanı sistemi otomatik olarak daha büyük bir kapasiteye sahip yeni bir underlying array oluşturur ve mevcut elemanları yeni array&#8217;e kopyalar. Bu işlem, programcıların manuel olarak array yeniden boyutlandırma işlemleriyle uğraşmasının önüne geçer ve dilin kullanım kolaylığını artırır.</li>
<li>Otomatik büyütme işleminde slice genellikle <strong>mevcut kapasitenin iki katı kadar</strong> büyütülür ancak çok büyük sayılarda bu oran farklı hesaplamalara göre yapılır.</li>
<li><code>append</code> fonksiyonunun kullanımı, slice&#8217;lara eleman eklemenin yanı sıra, slice&#8217;ları birleştirmek için de kullanılabilir. Bu fonksiyonun geri dönüş değeri, elemanların eklendiği yeni slice&#8217;dır. İşte <code>append</code> fonksiyonunun kullanımına dair bir örnek:</li>
</ol>
<p><script src="https://gist.github.com/yakuter/d1893a0311f1c14b1390def3332d743f.js"></script></p>
<h2>Channel ile Veri Taşıma</h2>
<p>Go programlama dilinde, channel&#8217;lar goroutine&#8217;ler arasında veri alışverişi yapmak için kullanılan güçlü araçlardır. Channel&#8217;lar üzerinden veri taşıma, Go&#8217;nun eşzamanlılık modelinin temel taşlarından biridir ve &#8220;<strong>Don&#8217;t communicate by sharing memory, share memory by communicating</strong>&#8221; felsefesini benimser. Bu yaklaşım, race condition gibi sorunların önüne geçer ve veri bütünlüğünü korur. Channel kullanımı, verilerin sıralı ve güvenli bir şekilde bir goroutine&#8217;den diğerine aktarılmasını sağlar, bu da özellikle birden çok iş parçacığı arasında koordinasyon gerektiren durumlar için idealdir. Channel&#8217;lar, belirli bir tip veri taşımak üzere tip güvenliği sağlar ve hem senkron (bloklayıcı) hem de asenkron (non-bloklayıcı) iletişim desenlerini destekler.</p>
<p>Aşağıda, Go&#8217;da channel kullanarak veri taşımanın nasıl gerçekleştirilebileceğine dair basit bir örnek verilmiştir. Bu örnek, bir goroutine içerisinden başka bir goroutine&#8217;e mesaj göndermeyi ve almayı gösterir:<br />
<script src="https://gist.github.com/yakuter/487adfee2df5e5387de11e956d688737.js"></script></p>
<p>Channel, sadece veri taşıma için değil, ayrıca senkronizasyon ve sinyal gönderme gibi bir çok farklı amaçla kullanılabilir. Şurada birçok farklı kullanım örneğine değinmiştim. Bununla birlikte channel kullanırken birçok konuya dikkat etmek, manuel olarak süreci yönetmek gerekir: channelda veri kaldı mı, channel kapalı mı, kapasitesi uygun mu, blocking mi&#8230; İşte bu tür şeyleri manuel kontrol etmek yerine temelinde yine channel kullanan io.Pipe veri taşımada daha kullanışlı bir araç olarak karşımıza çıkmaktadır. Ancak io.Pipe&#8217;e geçmeden önce Go&#8217;nun iki önemli araçlarında io.Writer ve io.Reader interface&#8217;lerini anlamamız gerekir.</p>
<h2>io.Writer ve io.Reader Kullanımı</h2>
<p>Go programlama dilinde, <a href="https://github.com/golang/go/blob/b6ca586181f3f1531c01d51d632b50b2c7c784ba/src/io/io.go#L90"  target="_blank" rel="external nofollow"   class="wp-links-icon">io.Writer</a> ve <a href="https://github.com/golang/go/blob/b6ca586181f3f1531c01d51d632b50b2c7c784ba/src/io/io.go#L55"  target="_blank" rel="external nofollow"   class="wp-links-icon">io.Reader</a> interfaceleri, veri yazma ve okuma işlemleri için standart bir arayüz sağlar. Bu interfaceler, Go&#8217;nun I/O işlemlerinin temelini oluşturur. <code>io.Writer</code> interface&#8217;i, bir veri akışına veri yazmayı sağlayan <code>Write</code> metodunu tanımlar. Bu interface, dosyalara, buffer&#8217;lara, ağ bağlantılarına ve daha fazlasına veri yazmak için kullanılabilir. Öte yandan, <code>io.Reader</code> interface&#8217;i, bir veri akışından veri okumayı sağlayan <code>Read</code> metodunu tanımlar. Bu interface aracılığıyla dosyalardan, bellek tamponlarından, ağ bağlantılarından ve benzeri kaynaklardan veri okunabilir. Her iki interface de, Go&#8217;nun standart kütüphanesinde yer alan çeşitli paketler tarafından geniş bir şekilde kullanılır ve Go&#8217;nun polimorfik I/O işlemlerini destekleme yeteneğinin bir göstergesidir. <code>io.Writer</code> ve <code>io.Reader</code>&#8216;ın bu genel arayüzleri sayesinde, Go geliştiricileri farklı veri kaynakları ve hedefleri arasında kolayca geçiş yapabilir ve veri akışlarını esnek bir şekilde yönetebilir.</p>
<p><code>type Writer interface {<br />
Write(p []byte) (n int, err error)<br />
}</code></p>
<p><code>type Reader interface {<br />
Read(p []byte) (n int, err error)<br />
}</code></p>
<h3>io.Reader&#8217;da En Çok Yapılan Hata</h3>
<p>io.Reader&#8217;ı implemente eden bir Read methodunda en sık yapılan hata, <code>Read</code> metodunun her çağrısında tam olarak istenilen miktarda veri okuyacağını varsaymaktır. Ancak, bu metod daha az veri okuyabilir veya <code>io.EOF</code> hatası dönebilir. Bu sorun genellikle şu durumlarda ortaya çıkabilir:</p>
<ol>
<li><strong>Veri Kaynağında Yeterli Veri Yok</strong>: Eğer veri kaynağında sadece 5 byte veri kaldıysa, <code>Read</code> çağrısı yalnızca bu 5 byte&#8217;ı okur ve size geri döndürür. Bu durumda, <code>n</code> (okunan byte sayısı) değeri 5 olur.</li>
<li><strong>Ağ Gecikmeleri ve Veri Parçalanması</strong>: Ağ üzerinden veri okurken, veri paketleri parçalara ayrılabilir veya gecikmeler yaşanabilir. Bu nedenle, her <code>Read</code> çağrısı farklı miktarda veri alabilir. Bir çağrıda 8 byte beklerken, gerçekte daha az veri okunabilir.</li>
<li><strong>Dosya Sonu (<code>EOF</code>) Durumu</strong>: Dosya sonuna ulaşıldığında, kalan veri 8 byte&#8217;tan azsa, <code>Read</code> yalnızca kalan veriyi okur ve <code>io.EOF</code> hatası döndürür.</li>
</ol>
<h4>Hatalı okuma örneği:</h4>
<p><script src="https://gist.github.com/yakuter/d74659ace1bc596fc3469f57a026ae77.js"></script></p>
<h4>Doğru okuma örneği</h4>
<p><script src="https://gist.github.com/yakuter/154152f4e743bcac5f80e4a8ec4cb484.js"></script></p>
<h2>bytes.Buffer Kullanımı</h2>
<p><code>bytes.Buffer</code> genellikle bellekte veri saklamak ve bu veri üzerinde çeşitli okuma/yazma işlemleri yapmak için kullanılır. bytes.Buffer, hem <strong>io.Reader</strong> hem de <strong>io.Writer</strong> interface&#8217;lerini uygular, bu sayede veriyi arabellekte saklayabilir ve gerektiğinde üzerinde işlemler gerçekleştirebilirsiniz. bytes.Buffer, bellek üzerinde çalıştığı için, genellikle statik veri üzerinde çalışırken veya veri dönüştürme işlemlerinde tercih edilir.</p>
<p><script src="https://gist.github.com/yakuter/460a25bd235ff9ebc138ca0b1e4de486.js"></script></p>
<h2>bufio Kullanımı</h2>
<p>Go&#8217;nun <code>bufio</code> paketi, buffered giriş ve çıkış işlemleri için güçlü araçlar sunar. Bu paket, <strong>dosya okuma/yazma</strong> işlemleri, <strong>ağ üzerinden veri alışverişi</strong> ve standart giriş/çıkış işlemleri gibi I/O işlemlerini daha verimli hale getirmek için kullanılır. <code>bufio</code> paketi içindeki <code>Reader</code> ve <code>Writer</code> yapıları, büyük veri bloklarını işlerken veya sık sık okuma ve yazma işlemleri gerçekleştirirken performansı artırır. Tamponlama mekanizması sayesinde, <code>bufio</code> paketi, uygulamaların daha az sistem çağrısı yapmasını sağlayarak I/O işlemlerinin hızını önemli ölçüde iyileştirebilir. Ayrıca, <code>bufio.Scanner</code> yapısı, satır satır veya belirli bir ayırıcıya göre veri okuma işlemlerini kolaylaştırır, bu da özellikle metin tabanlı veri işlerken oldukça yararlıdır.</p>
<p>Aşağıda, <code>bufio</code> paketini kullanarak bir dosyadan satır satır okuma yapılmasını gösteren bir örneği bulabilirsiniz:</p>
<p><script src="https://gist.github.com/yakuter/08264468a52dab884ab604ded3488790.js"></script></p>
<h2>io.Pipe&#8217;ın Kullanımı</h2>
<p>Go&#8217;nun <code>io</code> paketi, çeşitli giriş/çıkış işlemleri için güçlü araçlar sunar ve <code>io.Pipe</code> bu araçlardan biridir. <code>io.Pipe</code> bir pipe (boru) oluşturarak, bir yazma işlemi ile bir okuma işlemi arasında veri akışı sağlar. Bu, genellikle farklı goroutine&#8217;ler arasında veri aktarımı yaparken kullanılır. <code>Pipe</code> fonksiyonu, bir <code>io.PipeReader</code> ve bir <code>io.PipeWriter</code> döndürür; <code>PipeWriter</code> üzerine yazılan her şey, <code>PipeReader</code> tarafından okunabilir hale gelir. Bu yapı, özellikle stream edilen veriler veya büyük veri setlerinin işlenmesinde oldukça yararlıdır çünkü verilerin tamamının belleğe alınmasını gerektirmez. Ancak, <code>io.Pipe</code> kullanırken dikkat edilmesi gereken bazı püf noktaları vardır:</p>
<ol>
<li><strong>Blokaj ve Deadlock Riski</strong>: <code>PipeWriter</code>&#8216;a yazma işlemi, ilgili <code>PipeReader</code> tarafından okunana kadar bloke olabilir. Eğer okuma ve yazma işlemleri aynı gorutinde gerçekleştirilirse, deadlock&#8217;a yol açabilir. Bu yüzden, okuma ve yazma işlemlerinin farklı goroutine&#8217;lerde yapılması önerilir.</li>
<li><strong>Hata Yönetimi</strong>: <code>PipeWriter</code> üzerine yazma işlemi sırasında veya <code>PipeReader</code> üzerinden okuma işlemi sırasında oluşan hatalar, dikkatli bir şekilde yönetilmelidir. Yazma veya okuma işlemi başarısız olursa, ilgili hata nesnesi ilgili yöntem tarafından döndürülür.</li>
<li><strong>Kaynakların Yönetimi</strong>: <code>PipeReader</code> ve <code>PipeWriter</code> kullanımdan kaldırıldığında, <code>Close</code> metodları çağrılarak kaynakların serbest bırakılması gerekir. Bu, kaynak sızıntılarını önlemek için önemlidir.</li>
</ol>
<p><code>io.Pipe</code> kullanımına dair basit bir örnek:<br />
<script src="https://gist.github.com/yakuter/29e0aa2981a783f821cf6f05c4fec4a6.js"></script></p>
<blockquote>
<h3>os.Pipe nedir?</h3>
<p><code>os.Pipe</code>, Go&#8217;nun <code>os</code> paketi içinde yer alır ve işletim sistemi seviyesinde bir pipe mekanizması sağlar. Bu yapı, işletim sisteminin sunduğu pipe mekanizmasını kullanarak iki dosya tanıtıcısı (<code>file descriptor</code>) arasında bir veri akışı kanalı oluşturur. <code>os.Pipe</code> genellikle, harici komutları çalıştırırken ve işletim sistemi seviyesindeki işlemler sırasında kullanılır. Örneğin, bir çocuk süreç (<code>child process</code>) ile ebeveyn süreç (<code>parent process</code>) arasında veri iletişimi kurmak için kullanılabilir. <code>os.Pipe</code> doğrudan işletim sistemi kaynaklarını kullanır ve bu nedenle işletim sistemi ile daha yakın bir etkileşime sahiptir.</p></blockquote>
<h3>io.Copy Kullanımı</h3>
<p><code>io.Copy</code> fonksiyonu, Go&#8217;nun <code>io</code> paketinde bulunan ve bir veri akışını bir <code>io.Reader</code> arayüzünü uygulayan bir kaynaktan, <code>io.Writer</code> arayüzünü uygulayan bir hedefe etkin bir şekilde aktarmak için tasarlanmış bir araçtır. Bu fonksiyon, genellikle dosya okuma/yazma işlemleri, ağ üzerinden veri alışverişi ve benzeri I/O işlemlerinde kullanılır. <code>io.Copy</code>&#8216;nin temel avantajı, veri aktarım işleminin &#8220;<strong>buffering</strong>&#8221; mekanizması üzerinden otomatik olarak yönetilmesi ve büyük veri kümelerinin belleğe yüklenmesine gerek kalmadan akışkan bir şekilde transfer edilmesidir. Bu, özellikle kaynak ve hedef arasında büyük boyutlu verilerin aktarılması gerektiğinde önemli bir performans ve verimlilik kazancı sağlar.</p>
<p><script src="https://gist.github.com/yakuter/83cab3c9dc5650f3137675cd83120ad7.js"></script></p>
<h2>Örnekler</h2>
<h3>HTTP Request ile Dosya Gönderme</h3>
<p><code>io.Pipe</code> kullanarak bir veriyi stream edip bir HTTP request&#8217;inde nasıl kullanabileceğinize dair bir örnek yapalım. Bu örnekte, yerel bir dosyayı okuyup bu veriyi <code>http.Post</code> fonksiyonu ile bir HTTP sunucusuna gönderen basit bir Go programı yazacağız. Bu işlem sırasında, <code>io.Pipe</code> kullanarak dosya içeriğini doğrudan HTTP request body&#8217;sine stream edeceğiz, böylece büyük dosyalarla çalışırken bellek kullanımını optimize edebiliriz.</p>
<p><script src="https://gist.github.com/yakuter/2ff33dce717af25397cbf9033e054232.js"></script></p>
<h3>HTTP Server ile Dosya Serve Etme</h3>
<p>HTTP üzerinden büyük dosyaları stream etmek, sunucu kaynaklarını etkili bir şekilde yönetmek ve kullanıcılara hızlı bir deneyim sunmak için etkili bir yöntemdir. Geleneksel dosya sunumundan farklı olarak, streaming ile dosya, diskten okunduğu gibi parça parça gönderilir. Bu yöntem, özellikle büyük dosyalarla çalışırken veya hafızada üretilen üretilen içeriği sunarken server belleğinin daha az kullanılmasını sağlar.</p>
<p>Streaming, özellikle aşağıdaki senaryolarda faydalıdır:</p>
<ul>
<li><strong>Büyük dosyaların işlenmesi</strong>: Sunucu üzerindeki bellek kullanımını azaltır çünkü tüm dosyanın belleğe yüklenmesine gerek yoktur.</li>
<li><strong>Gerçek zamanlı veri sunumu</strong>: İçeriğin sürekli güncellendiği canlı veri akışları veya gerçek zamanlı loglar için idealdir. Finansal piyasalar, sosyal medya akışları, video ve ses yayınları bunlara örnek olarak verilebilir.</li>
<li><strong>Ağ verimliliği önemli olduğunda</strong>: İstemciler, tüm dosya indirilmeden içeriği işlemeye veya görüntülemeye başlayabilir.</li>
<li><strong>Medya için adaptif bitrate streaming</strong>: İstemcinin bant genişliğine göre video veya ses içeriğinin kalitesinin gerçek zamanlı olarak ayarlanması.</li>
</ul>
<p><script src="https://gist.github.com/yakuter/87dacd9e39a7a8f2681bd6c3d33684bf.js"></script></p>
<p><a href="https://www.yakuter.com/go-ile-veri-kopyalama-ve-tasima-teknikleri/">Go ile Veri Kopyalama ve Taşıma Teknikleri</a> yazısı ilk önce <a href="https://www.yakuter.com">Yakuter</a> üzerinde ortaya çıktı.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.yakuter.com/go-ile-veri-kopyalama-ve-tasima-teknikleri/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
