2017-03-20 21 views
0

를 '가져 오기'이것은 내가 가진이 내가 무엇을 얻을 "-u는 github.com/kataras/iris/iris 가서"내가 봤는데 내 코드아이리스 오류 - 해결되지 않은이

`package main 
import "github.com/kataras/iris" 
func main() { 
    iris.Get("/hi", func(ctx *iris.Context) { 
     ctx.Writef("Hi %s", "iris") 
    }) 
    iris.Listen(":8080") 
}` 

입니다 Surving과 여전히 이것을 해결할 수 없습니다.

./IRIS.go:6 : 정의되지 않은 : iris.Get
./IRIS.go:9 : 정의되지 않은 : iris.Listen

이 내 처음이 프레임 워크를하려고을, 나는 페이지 https://docs.iris-go.com/에서 다음 I 쉽게 것,하지만 정말, 난 단지 조리개를 설치 할 수 없습니다, 이것은 내가

제발 도와주세요 내 IDE로 인 IntelliJ 아이디어를 사용하고 처음으로 악화 안녕하세요 세계

인 것처럼. 감사합니다

+2

저장소에 안녕하세요 세계 예제가있다 더 나은 튜토리얼 : https://golang.org/doc/articles/wiki/ - 나중에 혼동을 줄일 수 있습니다. – elithrar

+0

안녕하세요, golang 문서가 제대로 작동하는지는 의심의 여지가 없지만 홍채 문서가 완벽하게 작동하지 않습니다. 답장을 보내 주셔서 감사합니다. 어쩌면 설명서가이 연령대에서 다시 작동하지 않을 수 있습니다. –

+2

@BudayaLanu : 홍채를 피할 것입니다 (나는 가능한 한 홍채를 실제로 피할 것입니다.) (http://www.florinpatan.ro/2016/10/why-you-should-not-use-iris-for-your-go.html)) . std lib의 기본 사항부터 시작하여 표준 문서 ([Go To Write Code] (https://golang.org/doc/code.html))부터 시작하십시오. – JimB

답변

0

https://github.com/kataras/irishttps://iris-go.comhttps://docs.iris-go.com는 그런 것들의 많은 예제를 가지고 있기 때문에 그것은 당신이, 당신은 아마 아이리스의 타사 포크를 확인할 것을 요청 시간을 보낼 아니라 아이리스 자체가 어디에 해당 코드를 찾았어요, 재미 단편?

올바른 방법 :

// file: main.go 
package main 
import "github.com/kataras/iris" 

func main() { 
    app := iris.New() 
    // Load all templates from the "./views" folder 
    // where extension is ".html" and parse them 
    // using the standard `html/template` package. 
    app.RegisterView(iris.HTML("./views", ".html")) 

    // Method: GET 
    // Resource: http://localhost:8080 
    app.Get("/", func(ctx iris.Context) { 
     // Bind: {{.message}} with "Hello world!" 
     ctx.ViewData("message", "Hello world!") 
     // Render template file: ./views/hello.html 
     ctx.View("hello.html") 
    }) 

    // Method: GET 
    // Resource: http://localhost:8080/user/42 
    app.Get("/user/{id:long}", func(ctx iris.Context) { 
     userID, _ := ctx.Params().GetInt64("id") 
     ctx.Writef("User ID: %d", userID) 
    }) 

    // Start the server using a network address. 
    app.Run(iris.Addr(":8080")) 
} 

<!-- file: ./views/hello.html --> 
<html> 
<head> 
    <title>Hello Page</title> 
</head> 
<body> 
    <h1>{{.message}}</h1> 
</body> 
</html> 

$ go run main.go 
> Now listening on: http://localhost:8080 
> Application started. Press CTRL+C to shut down. 
: 여기

package main 
import "github.com/kataras/iris" 
func main() { 
    app := iris.New() 
    app.Get("/hi", func(ctx iris.Context) { // go > 1.9 
     ctx.Writef("Hi %s", "iris") 
    }) 
    app.Run(iris.Addr(":8080")) 
} 

다른 예를 들어, 클라이언트에 메시지가있는 템플릿 파일을 렌더링하는 간단한 서버입니다

아이리스에 대한 도움이 필요한 경우 언제든지 라이브 채팅 https://chat.iris-go.com을 통해 지원 팀에 연락 할 수 있습니다. 좋은 하루 되세요!

0

Go 1.8이 이동 응용 프로그램의 기본 호스트로 남아 있으면 소스 파일의 import 문에 github.com/kataras/iris/context 패키지를 선언하고 사용해야합니다. 난 당신과 함께 시작하는 것이 좋습니다 있지만 - https://github.com/kataras/iris/blob/v6/_examples/examples/hello-world/main.go :

package main 
import (
"github.com/kataras/iris" 
"github.com/kataras/iris/context" 
) 

func main() { 
app := iris.New() 
app.RegisterView(iris.HTML("./views", ".html")) 

app.Get("/", func(ctx context.Context) { 
    ctx.ViewData("message", "Hello world!") 
    ctx.View("hello.html") 
}) 

app.Run(iris.Addr(":8080")) 
}