๐คฏ 2020, Today I Learend
๋ฐฐ์ด ๋ด์ฉ์ ๊นํ๋ธ ๋๋ ์ด์๋ฅผ ํตํด ์ ์ฅํฉ๋๋ค.
cjaewon / til Goto Github PK
View Code? Open in Web Editor NEW๐คฏ 2021, Today I Learend
๐คฏ 2021, Today I Learend
๐คฏ 2020, Today I Learend
๋ฐฐ์ด ๋ด์ฉ์ ๊นํ๋ธ ๋๋ ์ด์๋ฅผ ํตํด ์ ์ฅํฉ๋๋ค.
type EXAMPLE struct {
a int
}
example := &EXAMPLE{}
example2 := &EXAMPLE{}
fmt.Println(&example, &example2)
example = example2
fmt.Println(&example, &example2)
์ ๊ฒฐ๊ณผ๋ ๋ค์๊ณผ ๊ฐ๋ค.
0xc0000ae018 0xc0000ae020
0xc0000ae018 0xc0000ae020
example = example2 ๋ฅผ ํ๊ธฐ ๋๋ฌธ์ ํฌ์ธํฐ ์ฃผ์๊ฐ ๊ฐ์์ผ ๋๋ค๊ณ ์๊ฐํ๋ค.
example.a ์ example2.a ์ ๊ฐ์ ํ์ธํด๋ณด๋ ๊ฐ์ ๊ฑธ ์ธ์งํ์๊ณ ๋ด๊ฐ ํฌ์ธํฐ์ ํฌ์ธํฐ ์ฃผ์๋ฅผ ์ถ๋ ฅํ๊ณ ์๋ค๋ ๊ฒ์ ์๊ฒ๋ฌ๋ค.
์ฒ์์๋ ๋ฐ์ ์ฒ๋ผ ์๊ฐํ๋ค.
ํ์ง๋ง ์๊ณ ๋ณด๋ ๋๋ธํฌ์ธํฐ์ ์ฃผ์๋ฅผ ๊ฐ์ ธ์ค๊ณ ์์๋ ๊ฒ์ด๋ค. ํฌ์ธํฐ์ ํฌ์ธํฐ ์ฃผ์๋ ์ด์ฐจํผ ๋ค๋ฅธ ๋ฉ๋ชจ๋ฆฌ ๊ณต๊ฐ์ ์ ์ฅ๋๋ฏ๋ก ๊ฐ์ ์๊ฐ ์๋ค.
fmt.Printf("%p %p", example, example2) // ํฌ์ธํฐ๊ฐ ๊ฐ๋ค.
์๋์ฒ๋ผ ๋๋ฌธ์๋ก ํด์ฃผ์ด์ผ ์ ๊ทผ์ด ๊ฐ๋ฅํ์ฌ ๊ฐ๋ค์ Decode ํ ํ ๋งตํํด์ค๋ค.
์๋ฌธ์๋ก ์์ฑํด์ Decode ํ ๋ ์ค๋ฅ๊ฐ ๋ฌ์๋ค.
type Step struct {
Name string `mapstructure:"name"`
Run string `mapstructure:"run"`
Uses string `mapstructure:"uses"`
With map[string]interface{} `mapstructure:"with"`
}
var steps []Step
trigger := config.GetString("on.push.trigger")
err := config.UnmarshalKey(fmt.Sprintf("jobs.%s.steps", trigger), &steps)
AWS ์์ฒญ ์๊ฐ์ด ์ง๋๋ฉด 504 ์๋ฌ๋ฅผ ๋ฐํํ๋ค.
์ ์์ ์ผ๋ก ์ํ๋๋ ๊ฒ ๊ฐ์ง๋ง ๋ฐ์ดํฐ๋ฒ ์ด์ค ์ฐ๊ฒฐ์ ๋์ด์ฃผ์ง ์์์ timeout ์ด ๋๋ ์ค๋ฅ์๋ค.
docker-compose ์ฌ์ฉ ๋๋ network ์ฌ์ฉ ์ค localhost ๋ฅผ ์ฌ์ฉํ๋ฉด ์๋๊ณ ํด๋น ์ปจํ
์ด๋ ์ด๋ฆ์ผ๋ก ์ฌ์ฉํด์ผ ํ๋ค. ๋ํ์ ์ผ๋ก localhost:3306
์ด ์๋๋ผ database:3306
์ผ๋ก ํด์ผํ๋ค. ์ด๊ฒ ๋๋ฌธ์ 2์ผ์ด ๋ ๋ผ๊ฐ๋ค. ๐ญ
๊ธฐ๋ณธ ์น์์ผ์ Object ๋ฐ์ดํฐ ๊ฐ์ ๋๊ฒจ์ฃผ๊ธฐ ์ํด
const string = JSON.stringify({ name, data });
ws.send(string);
์์ ๊ฐ์ ๋ฐฉ์์ ์ฌ์ฉํ๋ค. ํ์ง๋ง Rxjs ๋ฅผ ์ฌ์ฉํ ๋๋
// socket.js
const socket = webSocket(`${window.location.protocol === 'https:' ? 'wss' : 'ws'}://${location.host}`);
export default socket;
// index.js
socket.subscribe();
const request = { name, data };
socket.next(request);
์ด๋ฐ ์์ผ๋ก ์คํธ๋ง์ผ๋ก ๋ณ๊ฒฝ์์ด Object๋ก ๊ทธ๋ฅ ๋๊ฒจ์ฃผ๋ฉด ๋๋ค. ๋ด๋ถ์ ์ผ๋ก String ์ผ๋ก ๋ณํํ๋ ๊ฒ ๊ฐ๋ค.
JSON.parse ํด๋ string type ์ด ๋์์ ๋๋๋๋ฐ JSON.stringify ์ ์์ผ์ฃผ์ด์ ๋ฐ์ํ ๋ฌธ์ ์๋ค.
ERROR: Service 'server' failed to build : COPY failed: no source files were specified
package.json ์ ๊ฐ์ ธ์ค๊ธฐ ์ํด ์์์ ์์ ํด๋์์ ๋ณต์ฌํ๋๋ก ๋ง๋ค์๋๋ฐ ์ ์ฌ์ง๊ณผ ๊ฐ์ ์ค๋ฅ๊ฐ ๋ณ๋ค. ์ด๋ฅผ ํด๊ฒฐํ ๋ ค๋ฉด Dockerfile ์ด๋ ์๋ฒ๊ฐ ๊ฐ์ ์์น์ ์์ด์ผ ํ๋ค.
์คํ์ค๋ฒํ๋ก์ฐ ์์๋ ๋ฏธ๋ฆฌ ์์์ ์์ ํด๋์์ ๋น๋ํ๊ณ docker-compose up ํ๊ธฐ๋ฅผ ๊ถ์ฅํ๊ณ ์๋ค.
๋์ปค์ ์ปจํ
์ด๋ ์์์ Jenkins๋ฅผ ๊ฐ๋ํ๊ณ ์์ ๋
Jenkins ์์ docker ๊ด๋ จ ๋ช
๋ น์ด๋ฅผ ์ฌ์ฉํด์ผ ํ ๊ฒฝ์ฐ๊ฐ ์๋ค.
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- ../../volumns/jenkins_home:/var/jenkins_home
์์ ๊ฐ์ด ๋์ปค ๋ฐ๋ชฌ๊ณผ ์ฐ๊ฒฐ์์ผ์ฃผ์ด์ ํด๊ฒฐ ํ ์ ์๋ค.
์ด๋ฅผ ์ํด Jenkins ์ ๋์ปค ํด๋ผ์ด์ธํธ๋ง ๋ฐ๋ก ์ค์นํ ์ ์์ง๋ง ๋ณ๋ก ์ข์ ๋ฐฉ๋ฒ์ด๋ผ๊ณ ์๊ฐํ์ง๋ ์์๋ค.
volumes:
- /usr/bin/docker:/usr/bin/docker
- /var/run/docker.sock:/var/run/docker.sock
- ../../volumns/jenkins_home:/var/jenkins_home
๋ฐ๋ผ์ /usr/bin/docker ๋ํ ๊ฐ์ด Volumn ์ผ๋ก ์ค์ ํด์ฃผ๋ฉด์ ํด๊ฒฐํ์๋ค.
์์งํ ์ข์ ๋ฐฉ๋ฒ์ธ์ง๋ ์ ๋ชจ๋ฅด๊ฒ ๋ค. ๋์ปค ํด๋ผ์ด์ธํธ๋ง ์ฌ์ฉ ๊ฐ๋ฅํ๊ฒ ํด์ฃผ๋ plugin ์ด ์์๊น?
์๋ง๋ Buffer ๋ฅผ ํตํด์ ์ฝ๊ธฐ ๋๋ฌธ์ ํ๋ฒ ์ฝ์ผ๋ฉด ๋ฐ์ดํฐ๊ฐ ๋ ๋ผ๊ฐ๋ ๊ฒ ๊ฐ๋ค.
์ฝ๋๊ฐ ์๋ ์ฑ ์ eBook ์ผ๋ก ์ฌ๋๊ฒ ์ฝ๋ ์์ฑ ๋ฐ ๊ฐ๋ฐ์ ํธํจ.. ๐๐
.git ๊ณผ ๋ค๋ฅด๊ฒnode_modules
์ .dockerignore ์ ๊ธฐ์
ํ๋ฉด ํด๋น path ์๋ง ์ ์ฉ๋๋ ๊ฒ ๊ฐ๋ค.
**/node_modules
๋ค์๊ณผ ๊ฐ์ด ๋ช ์ํด์ฃผ์ด์ผ ํ๋ค.
<!-- index.html -->
{{ template "base.html" }}
{{ define "main" }}
<h1>Hello World</h1>
<a href="/hello">hello</a>
{{ end }}
<!-- hello.html -->
{{ template "base.html" }}
{{ define "main" }}
<a href="/">Travel it!</a>
{{ end }}
<!-- base.html -->
<main>
{{ block "main" . }}{{ end }}
</main>
์์ ๊ฐ์ด html ํ
ํ๋ฆฟ ์ฝ๋๋ค์ /web/layouts
์ /web/pages
์ ์ ์ํ๋ค.
๊ทธ๋ฆฌ๊ณ ๋ค์๊ณผ ๊ฐ์ ์ฝ๋๋ฅผ ํตํด์ ํ์ฑํด์๋๋ฐ {{ define }} ๋๋ฌธ์ index.html์ Tree๊ฐ hello.html ์ ๊ฐ์ ๋ฌธ์ ๊ฐ ๋ฐ์ํ๋ค.. ์๋ง ์คํํ๊ธฐ์ ์ ํ์ฑํ๋ ParseGlob
์์ ๋ฐ์ํ ๋ฌธ์ ์ธ ๊ฒ ๊ฐ์๋ค.
package templates
import (
"errors"
"html/template"
"io"
"github.com/labstack/echo/v4"
)
// Template is
type Template struct {
templates *template.Template
}
// Render performances html/template rendering
func (t *Template) Render(w io.Writer, name string, data interface{}, c echo.Context) error {
return t.templates.ExecuteTemplate(w, name, data)
}
// New creates an instance of Template
func New() *Template {
t := Template{
templates: template.Must(template.ParseGlob("web/*/*.html")),
}
return &t
}
์ด ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ๊ธฐ ์ํด templates์ templateMap์ผ๋ก ๋ณ๊ฒฝ์์ผ์ค ๋ค์ index.html, hello.html ์ ๋ฐ๋ก๋ฐ๋ก base.html ๊ณผ ํฉ์น ๋ค ์ ์ฅํด์ฃผ์๋ค. ๋ค์ ์ฝ๋์ ๊ฐ๋ค.
package templates
import (
"html/template"
"io"
"path/filepath"
"github.com/labstack/echo/v4"
)
// Template is
type Template struct {
templateMap map[string]*template.Template
}
// Render performances html/template rendering
func (t *Template) Render(w io.Writer, name string, data interface{}, c echo.Context) error {
return t.templateMap[name].ExecuteTemplate(w, "base.html", data)
}
// New creates an instance of Template
func New() *Template {
t := Template{
templateMap: map[string]*template.Template{},
}
layouts := template.Must(template.ParseGlob("web/layouts/*.html"))
pages, err := filepath.Glob("web/pages/*.html")
if err != nil {
panic(err)
}
for _, file := range pages {
base := filepath.Base(file)
tmpl := template.Must(template.ParseFiles(file))
tmpl.AddParseTree(layouts.Tree.Name, layouts.Tree)
t.templateMap[base] = tmpl
}
return &t
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.