echo로 만든 템플릿 상에서
<link rel="stylesheet" href="../../assets/css/style.css">
처럼 하기만 하면 될 줄 알았는데 안된다.
찾아보니 Static 함수를 사용해서
주소를 잡아줘야 되는 거 같다.
e.Static("/static", "assets")
main() 함수에 echo 실행 이후 위 코드처럼 static을 작성해주면
<link rel="stylesheet" href="/static/css/style.css">
이렇게만 써도 알아서 데려오더라.
파일 경로는 go폴더/assets/css/style.css
도움이 됐던 정보들
https://echo.labstack.com/guide/static-files/
Echo - High performance, minimalist Go web framework
Echo is a high performance, extensible, minimalist web framework for Go (Golang).
echo.labstack.com
https://www.alexedwards.net/blog/serving-static-sites-with-go
Serving Static Sites with Go - Alex Edwards
Getting started with Go? My book guides you through the start-to-finish build of a real world web application in Go — covering topics like how to structure your code, manage dependencies, create dynamic database-driven pages, and how to authenticate and
www.alexedwards.net
'공부공부 > 고' 카테고리의 다른 글
golang으로 만들어 본 토이 프로젝트 (0) | 2022.05.23 |
---|---|
golang의 Public, Private (0) | 2022.05.09 |
golang 구조체 전달 (0) | 2022.05.09 |
golang echo 템플릿 사용기 (0) | 2022.05.08 |
golang으로 만든 구글의 10가지 오픈 프로젝트 (0) | 2020.11.03 |