http://play.golang.org/p/BgnHN-GikU
var p1 = new(int)
var p2 *int = new(int)
var p3 = 0
var p4 *int
func main() {
fmt.Println(*p1, &p1, p1)
fmt.Println()
fmt.Println(*p2, &p2, p2)
fmt.Println()
fmt.Println(p3, &p3)
fmt.Println()
fmt.Println(p4, &p4)
}
Run Code Online (Sandbox Code Playgroud)
0 0x206a10 0x104382e0
0 0x206a14 0x104382f0
0 0x21ccc0
<nil> 0x206a18
httpd = make_server('', 80, server)
webbrowser.open(url)
httpd.serve_forever()
Run Code Online (Sandbox Code Playgroud)
这是跨平台工作,除非我在putty ssh终端上启动它.如何在一个单独的进程中欺骗控制台打开w3m浏览器,以便它可以继续启动服务器?
或者,如果在没有x的shell上运行时无法跳过webbrowser.open?
为什么invalid memory address or nil pointer dereference跑步时问候给我?
type Response struct {
Message string `json:"message"`
}
type ResponseList struct {
Items []*Response `json:"items"`
}
func (gs *GreetingService) List(r *http.Request, req *Request, resp *ResponseList) error {
greets := make([]*Response,2,2)
greets[0].Message="hello"
greets[1].Message="goodbye"
resp.Items = greets
return nil
}
Run Code Online (Sandbox Code Playgroud) 当我在js中定义这样的时间时
{expiry:new Date()}
Run Code Online (Sandbox Code Playgroud)
并像这样在go端点中创建一个struct
{Expiry time.Time `json:"expiry"`}
Run Code Online (Sandbox Code Playgroud)
我得到一个解析错误
"parsing time \"\"2006-01-02T15:04:05Z07:00\"\" as \"\"2006-01-02T15:04:05Z07:00\"\": cannot parse \"07:00\"\" as \"\"\""
Run Code Online (Sandbox Code Playgroud)
有什么建议?
req = db.openCursor();
req.customerData=new Array() //[{a:1}]
req.onsuccess = function(e) {
var cursor = e.currentTarget.result;
if (cursor) {
//console.log(cursor.value);
e.currentTarget.customerData.push(cursor.value);
e.currentTarget.customerData.push("hello?");
cursor.continue()
}
else {
console.log(e.currentTarget.customerData) //this always correct
}
}
console.log(req.customerData); //outside the onsuccess everything is gone?
Run Code Online (Sandbox Code Playgroud)
console.log(req);
当我在 chrome 控制台中打开对象时,我可以看到 customerData
console.log(req.customerData);
但是当我执行上述操作时它是空的?
替换new Array()为[{a:1}]
console.log(req.customerData);
我可以看到a其他物体
但后来又
console.log(req.customerData[0].a);
工作,其他对象消失了。
如何保存客户数据?我尝试只推送数字或文本,但在交易完成后同样如此。我不能把数据取出来只能在交易过程中在 console.log() 上显示?
我知道它一定是通过引用过去的,但是我输入的每个变量都消失了?
在下面添加了完整示例,只需在控制台中键入 write() 和 read()
<script>
var iDB
ready=function(){
var request = indexedDB.open("my-database",1);
request.onupgradeneeded = function(e) {
var db = e.currentTarget.result …Run Code Online (Sandbox Code Playgroud) 创建一个测试文件./bower_components/index.html,并运行go test在./.
为什么以下打印两行而不是第一行?
./bower_components/index.html
./bower_components/
Run Code Online (Sandbox Code Playgroud)
输出:
=== RUN TestRootHandler
./bower_components/index.html
./bower_components/ ???
--- PASS: TestRootHandler (0.00s)
main_test.go:32: 200 - ./bower_components/Hello World.html
PASS
ok
Run Code Online (Sandbox Code Playgroud)
码:
// RootHandler for HTTP
func RootHandler(root string, h http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
_, err := os.Open(root + r.URL.Path)
if err != nil {
fmt.Println(err.Error())
h.ServeHTTP(w, r)
return
}
fmt.Println(root + r.URL.Path)
r.URL.Path = root + r.URL.Path
h.ServeHTTP(w, r)
})
}
// TestRootHandler
func TestRootHandler(t *testing.T) …Run Code Online (Sandbox Code Playgroud) class Eq a where
(==), (/=) :: a -> a -> Bool
x /= y = not (x == y)
x == y = not (x /= y)
deriving instance Eq Bool
Run Code Online (Sandbox Code Playgroud)
我认为它会产生
instance Eq Bool where
True == True = True
False == False = True
Run Code Online (Sandbox Code Playgroud)
但是如何从类似的东西创建一个实例
newtype Sink p = Sink {unSink :: MVar (E.Iteratee (Message p) IO ())}
instance Eq (Sink p) where
?==? = True
Run Code Online (Sandbox Code Playgroud)
我只是使用派生而ghc会弄清楚自己吗?
deriving instance Eq (Sink p)
Run Code Online (Sandbox Code Playgroud)
PS我读过这篇文章,但它超出了我的理解能力 http://www.haskell.org/ghc/docs/7.6.1/html/users_guide/deriving.html
public class MyPrefs extends PreferenceActivity {
public static class MyPreferenceFragment extends PreferenceFragment
{
@Override
public void onCreate(final Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.preferences);
}
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
MyPreferenceFragment frag = new MyPreferenceFragment();
getFragmentManager().beginTransaction().replace(android.R.id.content, frag).commit();
Preference pref;
pref = frag.findPreference("pref_gps_updates");
pref.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
return true;
}
});
}
}
Run Code Online (Sandbox Code Playgroud)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.preference.Preference.setOnPreferenceChangeListener(android.preference.Preference$OnPreferenceChangeListener)' on a null object reference
我不明白为什么会发生此崩溃或我做错了什么?
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen …Run Code Online (Sandbox Code Playgroud)