• 카테고리

    질문 & 답변
  • 세부 분야

    데브옵스 · 인프라

  • 해결 여부

    미해결

PDF파일에 있는 소스 코드 링크 권한

20.08.23 09:18 작성 조회수 121

0

notion페이지 링크를 접속하면 권한이 없다고 나옵니다. 공개로 해 주셔야 할 것 같습니다.

https://www.notion.so/gasbugs/main go fdce9b0e3f70488f9634fca73350da13

제가 PDF 그대로 작성을 하였지만 아래와 같은 오류가 발생하고 있습니다.

./prog.go:21:6: syntax error: unexpected main, expecting (

PDF참고하여 지속적으로 확인해 보았지만 마지막 main() 구문에서 어떤 부분이 잘못 됐는지를 모르겠습니다.

package main

import (
	"fmt"
	"github.com/julienschmidt/httprouter"
	"net/http"
	"log"
	"os"
)

func Index(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {hostname, err :=os.Hostname()
	if err == nil {
		fmt.Fprint(w, "Welcome! " + hostname + "\n"
	} else {
		fmt.Fprint(w, "Welcome! ERROR\n")
	}
{


func main() {
	router := httprouter.New()
	router.GET("/", Index)
	
	log.Fatal(http.ListenAndServe(":8080", router))
}

답변 1

답변을 작성해보세요.

1

gasbugs님의 프로필

gasbugs

2020.08.23

안녕하세요 강사 최일선입니다.

여기로 접속해보시기 바랍니다.

https://www.notion.so/gasbugs/main-go-fdce9b0e3f70488f9634fca73350da13

말씀하신 문제는 괄호 문제로 보입니다. func Index 괄호가 반대로 닫혀있네요~

감사합니다.