OneinStack 下 iMagick 添加 WebP扩展


编译支持WebP模块的iMagick需要有libwebp的支持。

apt-get install libwebp-dev -y


然后进入 ~/oneinstack/include文件夹,编辑ImageMagick.sh文件:

cd ~/oneinstack/include

vi ImageMagick.sh


在带有 ./configure的两行后面添加 --with-webp=yes,修改后的效果:

./configure --prefix=${imagick_install_dir} --enable-shared --enable-static --with-webp=yes


如果已经安装有iMagick,先运行卸载命令,然后再重新编译安装:

~/oneinstack/uninstall.sh --php_extensions imagick #卸载

~/oneinstack/install.sh --php_extensions imagick #安装

Go语言教程之边写边学:基础练习:将年、月、日、小时、分钟、秒、毫秒、微秒和纳秒添加到当前日期时间

以下是在golang中进行常规时间计算的方法。AddDate用于日期计算,Add用于时间计算。

示例代码:

package main
 
import (
    "fmt"
    "time"
)
 
func main() {
    now := time.Now()
    fmt.Println("\nToday:", now)
     
    after := now.AddDate(1, 0, 0)
    fmt.Println("\nAdd 1 Year:", after)
     
    after = now.AddDate(0, 1, 0)
    fmt.Println("\nAdd 1 Month:", after)
     
    after = now.AddDate(0, 0, 1)
    fmt.Println("\nAdd 1 Day:", after)
     
    after = now.AddDate(2, 2, 5)
    fmt.Println("\nAdd multiple values:", after)
     
    after = now.Add(10*time.Minute)
    fmt.Println("\nAdd 10 Minutes:", after)
     
    after = now.Add(10*time.Second)
    fmt.Println("\nAdd 10 Second:", after)
     
    after = now.Add(10*time.Hour)
    fmt.Println("\nAdd 10 Hour:", after)
     
    after = now.Add(10*time.Millisecond)
    fmt.Println("\nAdd 10 Millisecond:", after)
     
    after = now.Add(10*time.Microsecond)
    fmt.Println("\nAdd 10 Microsecond:", after)
     
    after = now.Add(10*time.Nanosecond)
    fmt.Println("\nAdd 10 Nanosecond:", after)
}

输出:

Today: 2017-08-27 11:17:54.1224628 +0530 IST

Add 1 Year: 2018-08-27 11:17:54.1224628 +0530 IST

Add 1 Month: 2017-09-27 11:17:54.1224628 +0530 IST

Add 1 Day: 2017-08-28 11:17:54.1224628 +0530 IST

Add multiple values: 2019-11-01 11:17:54.1224628 +0530 IST

Add 10 Minutes: 2017-08-27 11:27:54.1224628 +0530 IST

Add 10 Second: 2017-08-27 11:18:04.1224628 +0530 IST

Add 10 Hour: 2017-08-27 21:17:54.1224628 +0530 IST

Add 10 Millisecond: 2017-08-27 11:17:54.1324628 +0530 IST

Add 10 Microsecond: 2017-08-27 11:17:54.1224728 +0530 IST

Add 10 Nanosecond: 2017-08-27 11:17:54.12246281 +0530 IST
Go语言教程之边写边学:将结构字段转换为映射字符串

下面的代码片段声明了一个结构类型MyStruct,其中包含字段Name和Score。名为myMap的映射具有字符串键和一个空接口作为创建的值。

示例代码:

package main

import (
	"encoding/json"
	"fmt"
)

type MyStruct struct {
	Name  string
	Score int
}

func main() {
	ms := MyStruct{Name: "John", Score: 34}

	var myMap map[string]interface{}
	data, _ := json.Marshal(ms)
	json.Unmarshal(data, &myMap)

	fmt.Println(myMap["Name"])
	fmt.Println(myMap["Score"])
}

输出:

John
34
Go语言教程之边写边学:使用空接口动态添加结构体成员

示例代码:

package main

import (
	"fmt"
)

type Before struct {
	m string
}

func append(b interface{}) interface{} {
	return struct {
		Before
		n string
	}{b.(Before), "rest"}
}

func main() {
	b := Before{"test"}
	a := append(b)
	fmt.Println(a)
}

输出:

{{test} rest}
Go语言教程之边写边学:Goroutines和Channels练习:启动多个Goroutine,每个goroutine都向一个频道添加值

该程序从10个Goroutines开始。我们创建了一个ch字符串通道,并通过同时运行10个goroutines将数据写入该通道。箭头相对于通道的方向指定是发送还是接收数据。指向ch的箭头指定我们要写入通道ch。箭头从ch向外指向指定我们正在从通道ch读取。

 

示例代码:main.go

package main

import (
	"fmt"
	"strconv"
)

func main() {
	ch := make(chan string)

	for i := 0; i < 10; i++ {
		go func(i int) {
			for j := 0; j < 10; j++ {
				ch <- "Goroutine : " + strconv.Itoa(i)
			}
		}(i)
	}

	for k := 1; k <= 100; k++ {
		fmt.Println(k, <-ch)
	}
}

 

输出:

1 Goroutine : 9
2 Goroutine : 9
3 Goroutine : 2
4 Goroutine : 0
5 Goroutine : 1
6 Goroutine : 5
7 Goroutine : 3
8 Goroutine : 4
9 Goroutine : 7
10 Goroutine : 6
....................
  • 当前日期:
  • 北京时间:
  • 时间戳:
  • 今年的第:18周
  • 我的 IP:3.148.236.97
农历
五行
冲煞
彭祖
方位
吉神
凶神
极简任务管理 help
+ 0 0 0
Task Idea Collect