<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <title>Go programming language</title>
    <link>https://go-lang.tistory.com/</link>
    <description></description>
    <language>ko</language>
    <pubDate>Mon, 15 Jun 2026 00:07:44 +0900</pubDate>
    <generator>TISTORY</generator>
    <ttl>100</ttl>
    <managingEditor>자연&amp;amp;사람</managingEditor>
    <image>
      <title>Go programming language</title>
      <url>https://tistory1.daumcdn.net/tistory/3470571/attach/11ee899527134972995a7e42cc7bb87a</url>
      <link>https://go-lang.tistory.com</link>
    </image>
    <item>
      <title>File에서 Line 단위로 데이터 읽기</title>
      <link>https://go-lang.tistory.com/8</link>
      <description>&lt;p&gt;&lt;figure class=&quot;imageblock alignLeft&quot; data-ke-mobileStyle=&quot;widthOrigin&quot; data-filename=&quot;question.jpg&quot; data-origin-width=&quot;313&quot; data-origin-height=&quot;313&quot;&gt;&lt;span data-url=&quot;https://blog.kakaocdn.net/dn/w2EVc/btrpW7ocXvV/F0kkxVmCddwMNSnrCGW31k/img.jpg&quot; data-phocus=&quot;https://blog.kakaocdn.net/dn/w2EVc/btrpW7ocXvV/F0kkxVmCddwMNSnrCGW31k/img.jpg&quot;&gt;&lt;img src=&quot;https://blog.kakaocdn.net/dn/w2EVc/btrpW7ocXvV/F0kkxVmCddwMNSnrCGW31k/img.jpg&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2Fw2EVc%2FbtrpW7ocXvV%2FF0kkxVmCddwMNSnrCGW31k%2Fimg.jpg&quot; onerror=&quot;this.onerror=null; this.src='//t1.daumcdn.net/tistory_admin/static/images/no-image-v1.png'; this.srcset='//t1.daumcdn.net/tistory_admin/static/images/no-image-v1.png';&quot; loading=&quot;lazy&quot; width=&quot;313&quot; height=&quot;313&quot; data-filename=&quot;question.jpg&quot; data-origin-width=&quot;313&quot; data-origin-height=&quot;313&quot;/&gt;&lt;/span&gt;&lt;/figure&gt;
&lt;/p&gt;
&lt;pre id=&quot;code_1641538569414&quot; class=&quot;html xml&quot; data-ke-language=&quot;html&quot; data-ke-type=&quot;codeblock&quot;&gt;&lt;code&gt;package main

import(
    &quot;bufio&quot;
    &quot;fmt&quot;
    &quot;log&quot;
    &quot;os&quot;
)

func main() {

    // func os.Open(name string) (*File, error)
    // 파일 열기
    file, err := os.Open(&quot;sample.txt&quot;)

    // 파일 open에 실패한 경우
    if err != nil {
        log.Fatal(err)
    }

    // func bufio.NewScanner(r io.Reader) *Scanner
    // 라인 단위로 읽을 Scanner 생성 
    scanner := bufio.NewScanner(file)

    // func (s *Scanner) Scan() bool
    // 1줄 읽기 성공 여부 확인
    for scanner.Scan() {
        // func (s *Scanner) Text() string
        // 방금 읽은 1줄의 문자열을 얻는다.
        fmt.Println(scanner.Text())
    }
    
    // func (s *Scanner) Err() error
    if err := scanner.Err(); err != nil {
        log.Fatal(err)
    }

    // func (f *File) Close() error
    // open된 파일 close
    file.Close()
}&lt;/code&gt;&lt;/pre&gt;
&lt;p style=&quot;font-size: 1.12em;&quot; data-ke-size=&quot;size16&quot;&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style=&quot;font-size: 1.12em;&quot; data-ke-size=&quot;size16&quot;&gt;&amp;nbsp;&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&amp;nbsp;&lt;/p&gt;</description>
      <category>go 활용/File처리</category>
      <author>자연&amp;amp;사람</author>
      <guid isPermaLink="true">https://go-lang.tistory.com/8</guid>
      <comments>https://go-lang.tistory.com/8#entry8comment</comments>
      <pubDate>Fri, 7 Jan 2022 20:04:53 +0900</pubDate>
    </item>
  </channel>
</rss>