2016-08-21 22 views
1

如何測試require是否在clojure中工作。在REPL中的要求返回nil。我不知道是否意味着它的工作。 oauth的命名空間似乎沒有設置。clojure要求不設置名稱空間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

實在不行把你require-main功能;必須在評估文件時對其進行評估,以便識別名稱空間別名。你應該把它放在你的ns的形式:

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

(NS hello.core) (要求'嘰嘰喳喳'[oauth.client:as oauth]) – nathanengineer

+0

@glochild從['require'](https://clojuredocs.org/clojure.core/require)docs:「Use':require' in'ns'宏而不是直接調用它。「 –

相關問題