我正在尝试从库“spurious-aws-sdk-helper”加载两个命名空间(顺便说一下,我已经在本地安装了 - 这是我在部署到 Clojars 之前测试它)。我正在从if
语句中加载命名空间。
加载命名空间后,我调用一个由加载的命名空间之一提供的函数。
问题是,通过执行代码时,lein ring server
我收到一个 Java 异常,通知我我尝试访问的命名空间不可用。
但是如果我运行lein repl
然后(use 'spurious-clojure-example.routes.home)
相关的顶级命名空间;然后(require '[spurious-aws-sdk-helper.core :as core])
命名空间 - 就像我稍后将链接到的代码中演示的那样 - 然后命名空间将可用,随后对该函数的调用不会出错?
我不确定这是否是那些具有误导性的错误之一,实际上这不是我试图要求的命名空间,而是其中的问题?但是,如果这是真的,那么为什么在我自己手动调用时它会起作用lein repl
呢?
我指的代码是:https : //github.com/Integralist/spurious-clojure-example/blob/baseline/src/spurious_clojure_example/routes/home.clj#L9-L10
(ns spurious-clojure-example.routes.home
(:use [amazonica.aws.s3])
(:require [compojure.core :refer :all]
[environ.core :refer [env]]
[spurious-clojure-example.views.layout :as layout]))
(if (env :debug)
(do
(require '[spurious-aws-sdk-helper.core :as core])
(require '[spurious-aws-sdk-helper.utils :refer [endpoint cred]])
(core/configure {:s3 "test-bucket4"
:sqs "test-queue4"
:ddb (slurp "./resources/config/schema.yaml")})))
(def bucket-path "news-archive/dev/election2014-council_title")
(def content
(apply …
Run Code Online (Sandbox Code Playgroud) 在大多数语言中,存在围绕参数的约定.例如,在嵌套循环中,您可以i
在顶层使用j
,然后k
.
但在Clojure中我不知道会议是什么.我经常看到xs
函数参数的使用; 那为什么呢?这是否具体是什么意思?还有其他惯例吗?
我正在尝试在docker容器中运行nginx,同时安装配置和静态html文件以使其能够正常运行。据我所知,很简单的东西,但是我不断收到关于目录不是目录的错误?
我正在使用最新版本的Boot2Docker在Mac上运行此示例。
我具有以下文件夹结构:
% tree ~/Projects/Docker/nginx-example
.
??? html
? ??? test.html
??? nginx.conf
1 directory, 2 files
Run Code Online (Sandbox Code Playgroud)
的内容nginx.conf
如下:
http {
server {
listen *:80; # Listen for incoming connections from any interface on port 80
server_name ""; # Don't worry if "Host" HTTP Header is empty or not set
root /usr/share/nginx/html; # serve static files from here
}
}
Run Code Online (Sandbox Code Playgroud)
我尝试~/Projects/Docker/nginx-example
像这样运行容器(从目录内):
docker run --name nginx-container \
-v /Users/M/Projects/Docker/nginx-example/html:/usr/share/nginx/html:ro \
-v /Users/M/Projects/Docker/nginx-example/nginx.conf:/etc/nginx:ro \
-P -d nginx
Run Code Online (Sandbox Code Playgroud)
最初,我曾尝试过 …
我一直想知道为什么在 golang 中使用括号创建字节片段:
[]byte("foo")
Run Code Online (Sandbox Code Playgroud)
使用括号表示法创建字符串切片时:
[]string{"foo", "bar"}
Run Code Online (Sandbox Code Playgroud)
使用括号是否只是因为表达式需要单个值(例如 string "foo"
),因此括号被用作“分组”语法?
注意:使用“组”或“分组”来定义这种行为对我来说很可能是不正确的,但我没有更好的词可以使用。
我这么认为是因为 golang 在分组意义上也使用括号来处理诸如类型断言i.(T)
和指针取消引用之类的事情(*p).z
。