ICode9

精准搜索请尝试: 精确搜索
  • 【C语言】使用pipe,execlp,dup2实现ls | wc -l2022-08-17 16:01:48

    #include <stdlib.h> #include <string.h> #include <unistd.h> #include <errno.h> #include <pthread.h> void sys_err(const char *str) { perror(str); exit(1); } int main(int argc,char *argv[]) { int fd[2]; int r

  • JavaScript 异步函数的 Promisification 处理2022-08-15 10:32:10

    Promisification 是一个很长的词,表示一个编程范式的转变,即将接受回调的函数转换为一个返回类型为 Promise 的函数。 我们现实的开发项目中经常需要这种转换,因为许多函数和库都是基于回调的,但是 Promise 更方便,所以对它们进行 Promisification 处理是有意义的。 下面是一个简单的例

  • 在Go中如何正确重试请求2022-08-12 23:03:53

    转载请声明出处哦~,本篇文章发布于luozhiyun的博客:https://www.luozhiyun.com/archives/677 我们平时在开发中肯定避不开的一个问题是如何在不可靠的网络服务中实现可靠的网络通信,其中 http 请求重试是经常用的技术。但是 Go 标准库 net/http 实际上是没有重试这个功能的,所以本篇

  • 一个typescript版本的dao(数据库访问)层的封装2022-08-12 17:01:23

    首先学会使用mustache语法 select * from {{key1}}字符中{{key1}}会进行匹配map中的key 例如: let sql = select * from {{key1}}; let tableMapper = { "key1": "course", } let result = mustache.render(sql, tableMapper); console.log('

  • ubuntu下安装 electron时报 Cannot read property 'insert' of undefined2022-08-12 11:32:10

    npm ERR! Cannot read property 'insert' of undefined npm ERR! A complete log of this run can be found in:npm ERR! /home/jbjiang/.npm/_logs/2022-08-12T02_44_16_135Z-debug-0.log   问题原因   没有使用root权限。调用npm install 权限不足导致 的   解决方法 sud

  • 【原创】Promise异步编程2022-08-11 12:30:37

      show me the code function getPromise(cbk){ return (new Promise(cbk)); } getPromise(function (res,rej) { res("suc1") //只会执行一个,并把参数传递到catch或者then rej("err1") }).catch(function(err){ console.log(err,1) }).then(function

  • go build 的plugin模式2022-08-11 01:31:16

    go build 的plugin模式 -buildmode=plugin ​ Build the listed main packages, plus all packages that they ​ import, into a Go plugin. Packages not named main are ignored. plugin模式可以将package main 构建成一个Go 插件,并且可以在运

  • golang执行linux (2)2022-08-10 14:34:31

    目录 [−] 执行命令并获得输出结果 将stdout和stderr分别处理 命令执行过程中获得输出 命令执行过程中获得输出2 命令执行过程中获得输出3 改变执行程序的环境(environment) 预先检查程序是否存在 管道 管道2 原文: Advanced command execution in Go with os

  • golang执行linux2022-08-10 14:33:47

    func copyAndCapture(w io.Writer, r io.Reader) ([]byte, error) { var out []byte buf := make([]byte, 1024, 1024) for { n, err := r.Read(buf[:]) if n > 0 { d := buf[:n] out = append(out, d...)

  • go语言使用kafka2022-08-10 14:33:39

    Golang 语言中 kafka 客户端库 sarama 01 介绍 Apache Kafka 是一款开源的消息引擎系统。它在项目中的作用主要是削峰填谷和解耦。本文我们只介绍 Apache Kafka 的 Golang 客户端库 Sarama。Sarama 是 MIT 许可的 Apache Kafka 0.8 及更高版本的 Golang 客户端库。 如果读者朋友对

  • golang执行shell命令2022-08-10 14:32:26

    golang调用shell命令(实时输出, 终止等) 背景 是这样的,最近在研究一个定时任务系统的改造,可能有点像jenkins做到的那种吧。​可以输入shell命令,也可以执行py脚本等等,相比之前来说,也要能够及时停止!​但是遇到了这么个问题,golang执行py脚本的时候获取不到脚本的输出。 1首先来看看go

  • Golang 程序读取yaml配置文件2022-08-08 18:31:46

    1、安装依赖;   go get gopkg.in/yaml.v2 2、添加配置文件config.yaml; redis: port: 3306 user: redis mysql: userName: root passWord: mysql    3、编写go代码读取配置文件数据; package main import ( "fmt" "gopkg.in/yaml.v2" "os" ) type

  • IPC Namespace2022-08-07 19:04:03

    IPC Namespace IPC Namespace用来隔离System V IPC和POSIX message queues,每一个IPC Namespace都有自己的System V IPC和POSIX message queue。 package main import( "os/exec" "syscall" "os" "log" ) func main(){ cmd:=exec.Command("s

  • 【HarmonyOS】【ARK UI】怎么实现一个悬浮框2022-08-05 09:33:55

    ​参考资料 窗口 准备资料 权限配置 ohos.permission.SYSTEM_FLOAT_WINDOW config.json配置 config.json配置权限,代码如下 "reqPermissions": [ { "name": "ohos.permission.SYSTEM_FLOAT_WINDOW" } ], 在mianAbility进行配置,代码如下 pa

  • http/template2022-08-04 12:04:18

    http/template text/template包实现了数据驱动的模板,用于生成可防止代码注入的安全的HTML内容。它提供了和text/template包相同的接口,Go语言中输出HTML的场景都应使用html/template这个包。 模板与渲染 在一些前后端不分离的Web架构中,我们通常需要在后端将一些数据渲染到HTML文档

  • 使用Promise封装api(axios, wx.request, uni.request)2022-08-03 18:01:02

    1. 封装uni.request const BASE_URL = ' ' export const myRequest = (options) => { return new Promise(resolve, reject){ uni.request({ url : BASE_URL + options.url, header: { 'content-type'

  • Vue基础巩固--axios2022-08-01 16:31:28

    axios网络请求模块 常见的网络请求模块及优缺点对比: JSONP的原理和封装 JSONP原理回顾 JSONP请求封装 axios的内容详解 认识axios网络模块 发送基本请求 axios创建实例 axios拦截器的作用 Vue中发送网络请求有非常多的方式,在开发中如何选择? 选择一:传统的Ajax是基于XMLHttpRequ

  • 成绩文件读取写入2022-07-31 21:00:13

          const fs = require('fs') fs.readFile('./files/成绩.txt', 'utf8', function (err, dataStr) {     if (err) {         return console.log('读取文件失败' + err.message);     }     //console.log('读取文件成功' + dataSt

  • vue+gin上传文件2022-07-31 11:36:17

    前端 html <form action="" method="post" enctype="multipart/form-data"> <input id="fileUpload" type="file" name="upload"> <input type="button" @click="subm

  • go日志2022-07-30 12:34:09

    go日志 // log package log //cxg 2022-7-29 import ( "log" "os" "time" ) func GetCurDay() string { return time.Now().Format("2006-01-02") } func GetNow() string { return time.Now().Format("2

  • golang读取文件2022-07-30 00:02:05

    golang读文件 1、os.Open() //File文件读操作 func ReadFile() string { file, err := os.Open("./test.txt") if err != nil { fmt.Printf("err:%v\n", err) } defer file.Close() var chunk []byte buf := make([]byte, 100)

  • gin CRUD2022-07-29 22:02:34

    gin CRUD // units package dal //cxg 2022-7-29 import ( "net/url" "svrGIN/db" "svrGIN/model" "github.com/gin-gonic/gin/binding" "strings" "svrGIN/log" "github

  • 【Harmony OS】【ARK UI】js或ETS如何获取状态栏高度2022-07-29 17:04:07

    ​  在Harmony OS项目怎么获取状态高度?在开发中我们可以参考窗口的getAvoidArea和getTopWindow的api,分为“代码实现”,“运行效果”两个步骤进行实现 ​ ​   代码实现全部代码如下 import window from '@ohos.window'; @Entry @Component struct Index { @State statusBarH

  • golang gosoap2022-07-29 09:02:29

    package main import ( "encoding/xml" "fmt" "log" "net/http" "time" "github.com/tiaguinho/gosoap" ) type GetIPLocationResponse struct { XMLName xml.Name `xml:"c

  • multiplexer2022-07-28 14:05:14

    package meshimport ( "fmt" "io" "net" "strconv" "strings")type Listener interface { io.Closer Accept() (io.ReadWriteCloser, net.Addr, error)}type tcpListener struct { net.Listener}func (t *

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有