However, other Clojure constructs, such as doseq do not allocate closures internally:

; This works just fine
(go (doseq [c cs]
      (println (<! c)))
This is one thing to remember since many Clojure constructs create functions inside macros. The following are examples of code that will not work as one would expect:

(go (map <! some-chan))
(go (for [x xs]
      (<! x)))
The go macro stops translating at function creation boundaries. This means the following code will fail to compile, or may just throw a runtime error stating that
(go (let [my-fn (fn [] (<! c))] (my-fn)))

Limitations of core.async make implementation of cleanse-map not that straightforward. But the following one should work:


(defn cleanse-map [m]
  (let [entry-chs (map
                   (fn [[k v]]
                     (a/go
                       (if (chan? v)
                         [k (a/<! v)]
                         [k v])))
                   m)]
    (a/into {} (a/merge entry-chs))))

Recommend

Clojure Go Block Best Practices Unsupported constructs and other limitations in go blocks

Clojure Go Block Best Practices General advice

Clojure spec Guide Instrumentation and Testing Combining check and instrument

Clojure spec Guide Instrumentation and Testing Testing

Clojure spec Guide Instrumentation and Testing Instrumentation

Clojure spec Guide Instrumentation and Testing

Clojure spec Guide Generators Range Specs and Generators

Clojure spec Guide Generators Custom Generators

Clojure spec Guide Generators Using s/and Generators

Clojure spec Guide Generators Exercise

Clojure spec Guide Generators Sampling Generators

Clojure spec Guide Generators Project Setup

Clojure spec Guide A game of cards

Clojure spec Guide Macros

Clojure spec Guide Higher order functions

Clojure spec Guide Spec’ing functions

Clojure spec Guide Using spec for validation

Clojure spec Guide Sequences

Clojure spec Guide Collections

Clojure spec Guide multi-spec

Clojure spec Guide Entity Maps

Clojure spec Guide Explain

Clojure spec Guide Composing predicates

Clojure spec Guide Registry

Clojure spec Guide Predicates

Clojure spec Guide Getting started

Clojure Equality References Closures

Clojure Equality Equality and hash Other cases of hash inconsistent with =

Equality Equality and hash Historical notes on hash inconsistency for non-Clojure collections

Clojure Equality Equality and hash

Clojure Equality Numbers Floating point Not A Number

Clojure Equality Numbers Floating point numbers are usually approximations