2016-08-21 2 views
1

요구 사항이 클로저에서 작동하는지 어떻게 테스트 할 수 있습니까? REPL에서 require는 nil을 리턴합니다. nil이 작동했는지 여부는 알 수 없습니다. oauth의 네임 스페이스가 설정되지 않은 것 같습니다.clojure require가 네임 스페이스를 설정하지 않음 oauth

오류

에 의해 발생 : java.lang.RuntimeException가 : 그런 네임 스페이스 : OAuth를

(ns hello.core) 
(defn -main 
    [] 

    (require 'twitter '[oauth.client :as oauth]) 

    ;; Make a OAuth consumer 
    (def oauth-consumer (oauth/make-consumer <key> 
              <secret> 
              "https://api.twitter.com/oauth/request_token" 
              "https://api.twitter.com/oauth/access_token" 
              "https://api.twitter.com/oauth/authorize" 
              :hmac-sha1)) 

답변

5

그것은 넣어 작동하지 않는 당신의 -main 기능에 require; 네임 스페이스 별칭이 인식 될 수 있도록 파일이 평가 될 때 평가되어야합니다. 당신은 대신 ns 형태에 넣어해야합니다,

(ns hello.core 
    (:require [oauth.client :as oauth] 
      [twitter])) 
+0

(NS의 hello.core) 이 (필요 'twitter'[oauth.client : oauth]) – nathanengineer

+0

@glochild ['require'] (https://clojuredocs.org/clojure.core/require) 문서에서 :''ns'에': require'를 사용하십시오. 매크로를 직접 호출하는 것이 좋습니다. " –

관련 문제